GetObject(, “Word.Application”) Office 365

2020-01-20 09:38发布

问题:

After installing Office 365 my application code in vba is not working anymore

Set wrd = GetObject(, "Word.Application") 
wrd.Visible = True  
wrd.Documents.Open "C:\My Documents\Temp.doc"  
Set wrd = Nothing

Does someone has any ideas

It does'nt recornize Office 365 with this code above but if i install Office 2016 or 2013 it works.

回答1:

SOLVED !

Search in the registry for correct application name. On windows 7 you can find it in "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\RegisteredApplicati‌​ons". Then replace the new name in "Set wrd = GetObject(, "Word.Application")

Thanks to @pavanc

It was called Word.Application.16 instead of Word.Application



回答2:

I don't know if it's just a markdown error on your part, but your code needs to separate lines:

Set wrd = GetObject(, "Word.Application") 
wrd.Visible = True
wrd.Documents.Open "C:\My Documents\Temp.doc"  
Set wrd = Nothing

If this doesn't help, maybe you can be more precise about the error you're getting?