Writing whole Visual Basic in Applescript - Possible?

I have a Word macro that is run from applescript by the following code:

tell application "Microsoft Word"
	do Visual Basic "TestMacro"
end tell

.and that works fine.

However, this database will be accesssed by 3 or 4 users, and I would rather not put the macros on individual computers. If I have to change any of the macros, I would have to keep track and change it on all the computers, so I would rather save the hassle by having the macro in one central place in one place (i.e. the applescript).

Is there a way to enter the text of the macro into applescript? I tried but it told me there was a syntax error (it doesn’t seem to recognize ¶).

Any help would be greatly appreciated.


Martha :slight_smile:

Would you post the Visual Basic code? Offhand, I’d guess some characters need to be escaped.

FWIW, this works:

display dialog "¶"

Sure! Here it is:

Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)

With Selection.Find
    .Text = "apply:"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph

'Close temporary document
 ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

Thanks for any help, in advance!


This is what I found on another website:

—It seems to be working quite nicely. I hope this helps someone else as well!

Martha :smiley: