Reputation: 11
Hopefully this should be a simple one for anyone who understands COM. I have a VB script that uses the office spell checker to check what ever is added to the clipboard. This has been floating around for many years, but now that AutoHotkey supports COM objects I thought I would try converting it over to AHK. I don't know much about COM, but it's worked pretty well so far except for one line.
oWD.ActiveDocument.Close wdDoNotSaveChanges
I cannot figure out how to pass the
wdDoNotSaveChanges
constant to
oWD.ActiveDocument.Close
in AutoHotkey. If I use it as above from the VB script, I receive an "This line does not contain a recognized action" error. Sorry again about not using proper code tags, but I am visually impaired and the post editor is not completely accessible.
Upvotes: 0
Views: 499
Reputation: 1835
wdDoNotSaveChanges is an Office constant. Sometimes you can get lucky by Googling for "wdDoNotSaveChanges value", or sometimes you have to go digging. In this case, the google answer worked so the value is 0, so you would convert your code to:
oWD.ActiveDocument.Close(0)
or the slightly more self-documented:
oWD.ActiveDocument.Close(wdDoNotSaveChanges:=0)
The latter is a good trick for all API constants but you have to know where to look for the values.
Upvotes: 1