I have a script to create sheet specs from word docs and it worksnin R23 and R24 but when i try to run it in R25 i get this “AttributeError: ‘__ComObject’ object has no attribute ‘Open’”.
This is the code. Please excuse any typos. Ive had to do this on my phone because somehow this site got blacklisted and naturally IT doesnt come in until 10!
import Microsoft.Office.Interop.Word as Word
from System.Type import Missing
missing = Missing
word_application = Word.ApplicationClass()
word_application.Visible = False
wordDoc = forms.pick_file(file_ext="docx",init_dir="J:",multi_file = False, title = "Pick a .docx word document.")
document = word_application.Documents.Open(wordDoc, missing, True)
2025 switched versions of .Net. It is now .Net 8 - so I imagine your problem is on the .Net side with Word. From my cursory reading of where things are headed, you might be better off looking at OpenXML as your method for Excel and Word.
First make sure .Net 8 is installed. Example below is from the terminal in VS Code.
Decided to just start messing around with stuff. I don’t know what the “wordapp = Word.ApplicationClass()” part of the code does and tried to use Documents.Open() without it. I don’t know what the missing = Missing does either, but left it in.
This would be a reference to the Word application using interop.
doc = Word.Documents.Open(wordDoc, missing, True)
The open method for a word docuemnt has a lot of overloads. I’m assuming “missing” is a variable name and would be in the typical position for ConfirmConversions - a bool. Try setting that to False. (ConfirmConversions=False) or just omit it completely. But given that all the overloads are optional - it could be any number of things.
The 3rd argument is for ReadOnly.
The worDoc needs to either be a word document object, or in your case a fully qualified pathe to the document. My guess is your path is incorrect. Try:
r"C:\Some Directory\Some Document.docx"
The r will format and properly escape the \ for the path.
Obviously you have some more complete code and it would help if you posted it all to let us better answer your questions.