I am writing a program as a hobby. I'm trying to create a word document in python The icon will change when saved. The icon will look like a file on the left of the image. I would like a professor.
guide.py
import docx
doc = docx.Document()
doc.add_paragraph('Hello world!')
doc.save(r"C:\Users\deer\Desktop\aaaaaaaaaaaaaa.docx")
guide.py
import win32com.client
import docx
import pythoncom
pythoncom.CoInitialize() #Call this before starting Word
#Start Word:Create an Application object
Application=win32com.client.Dispatch("Word.Application")
#Display Word on the screen:Set Visible property to True
Application.Visible = True
doc = Application.Documents.Add()
doc.Content.Text = "Aiue Okakikukeko"
doc.SaveAs("C:\\Users\dokar\Desktop\\bbaaaaaaaaaaaaaa")
#Quit Word:Call the Quit method
Application.Quit()
pythoncom.CoUninitialize() #Call this after exiting Word
Recommended Posts