Forum Discussion
Word Blocked Macros
- Villi_BSep 12, 2022Copper Contributor
This happens on my PC with Office Professional Plus 2016 with Word documents, also I'm almost sure it happens with another version too. The update history says the last one was 16.0.15330.20196 released in June. Word is 2016 MSO (Bersion 2208 build 16.0.15601.20078) 32 bit. The thing which is confusing us is that the issue appears only on the second and subsequent documents. I checked if the file it says comes from a non trusted location already exists but no, it gest created when I try to open the second document from Visual Foxpro code via
obyWord=CREATEOBJECT("WORD.APPLICATION","")
obyWord.VISIBLE=.T.
obyWord.APPLICATION.WINDOWSTATE=1
obyWord.Documents.Open(pathToDocFile, True, True)because if I try to open another macro-enalbed doc file with a double click in Windows Explorer I don't get the dialog telling me the macros are being disabled. pathToDocFile points to a file in a folder I added to the Trusted Paths (I'm translating from the italian version) in Office
And it doesn' happen on every PC
- Sep 12, 2022
Villi_B Try using the following:
Dim bstartApp As Boolean On Error Resume Next Set objWord = GetObject(, "Word.Application") If Err Then bstartApp = True Set objWord = CreateObject("Word.Application") End If On Error GoTo 0 'Then, at the end of your code incorporate If bstartApp = True Then objWord.Quit End If
- shaargoDec 07, 2023Copper Contributor
how to use this code?
I face the same issue, but i am a user of a third party macro, not a developer
i don't know how to fix this issue