Reputation: 2269
I am trying to return the path of an active document in my Word for mac macro with the call
strFolder = ActiveDocument.Path
This gives the file name also.
Is there a command for just the path or a string operation to minus the ActiveDocument.Name
?
Upvotes: 1
Views: 3118
Reputation:
FWIW I think this problem was introduced in Word 2008, where the "path" and "full name" attributes have the same values (in Applescript, since there's no VBA there). The same VBA worked OK in Word 2004.
One potential problem in your existing solution is that a folder can have a name identical to a document, e.g. your document fullname could be
Macintosh HD:Users:me:Documents:mydoc.docx:mydoc.docx
If you needed to deal with that, you could consider something like
strFolder = left(ActiveDocument.Path, len(ActiveDocument.Path) - len(ActiveDocument.Name))
(perhaps something different needed for unsaved documents, too).
Upvotes: 1
Reputation: 2269
I don't know why this was happening, but a resolution is below...
strFolder = Replace(ActiveDocument.Path, ActiveDocument.Name, "")
Hope this can help someone else in the future!
Upvotes: 0