AndrewMozley
Programmer
I am running WORD from the command prompt and would like to define a macro which saves the file in the current folder.
So, from the command prompt, in folder myfolder, I invoke WORD
C:\myfolder winword a1.doc
Within the WORD session I can click on File | Save. Word is all prepared to save the file into myfolder. Within the Save as window I can change the filename to a2.doc. The file is then saved into myfolder as C:\myfolder\a2.doc
I can save this sequence of instructions as a macro [blue]macsavea2[/blue]. The relevant VisualBasic code is :
ActiveDocument.SaveAs FileName:="a2.doc", FileFormat:=wdFormatDocument . . .
However if I then execute this macro, the file is saved, not in the current directory, but in :
C:\Documents and settings\Myname\My documents
and this is not what I want.
It appears that the behaviour of the macro is different to the behaviour of the same command sequence executed interactively.
How can I make the macro save the file into the current folder? I would mention that the WORD could be invoked from a different folder, so I do not wish to specify the path name explicitly.
I have tried using the CurDir() function, but this also returns C:\Documents and settings\Myname\My documents unless I have already saved a document in the current folder.
So, from the command prompt, in folder myfolder, I invoke WORD
C:\myfolder winword a1.doc
Within the WORD session I can click on File | Save. Word is all prepared to save the file into myfolder. Within the Save as window I can change the filename to a2.doc. The file is then saved into myfolder as C:\myfolder\a2.doc
I can save this sequence of instructions as a macro [blue]macsavea2[/blue]. The relevant VisualBasic code is :
ActiveDocument.SaveAs FileName:="a2.doc", FileFormat:=wdFormatDocument . . .
However if I then execute this macro, the file is saved, not in the current directory, but in :
C:\Documents and settings\Myname\My documents
and this is not what I want.
It appears that the behaviour of the macro is different to the behaviour of the same command sequence executed interactively.
How can I make the macro save the file into the current folder? I would mention that the WORD could be invoked from a different folder, so I do not wish to specify the path name explicitly.
I have tried using the CurDir() function, but this also returns C:\Documents and settings\Myname\My documents unless I have already saved a document in the current folder.