GetObject(, “Word.Application”) Office 365

2020-01-20 10:00发布

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.

2条回答
2楼-- · 2020-01-20 10:14

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?

查看更多
劳资没心,怎么记你
3楼-- · 2020-01-20 10:25

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

查看更多
登录 后发表回答