1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

原因究明

Posted at
import win32com.client

def open_word_document(doc_path):
    try:
        word_app = win32com.client.Dispatch("Word.Application")
        word_app.Visible = False
        doc = word_app.Documents.Open(doc_path)
        print("Word document opened successfully.")
        doc.Close()
        word_app.Quit()
    except Exception as e:
        print("Error:", e)

# 実行例
doc_path = r"C:\path\to\your\document.docx"  # ファイルパスを確認
open_word_document(doc_path)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?