Using MS Word FileSaveAs macro from the command line.

How do I start MS Word from the command line and instruct it to save a specified *.rtf file as a *.doc file without having to make additional keyboard or mouse entries?

I'm trying to start Word with the FileSaveAs macro ...
Winword.exe /mFileSaveAs MyFile.rtf
... and I want Word to create MyFile.doc.  But when it runs the macro, it pops up the "Save As" window, requiring operator interaction.  Is there a way I can tell the FileSaveAs macro what to do from the command line?

My environment is Windows 2000, MS Word 2000.
chighAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
Hmm. Sat with that as a solution for two hours waiting for my connection to return.

Now it looks as if you might have wanted to read as .rtf and save as .doc. If so, then do it like this:

Sub MyFileSave()
    Dim strName As String
    Dim strStem As String
    Dim strNewName As String
   
    strName = ActiveDocument.Name
    strStem = Split(strName, ".")(0)
    strNewName = strStem & ".doc"
    ActiveDocument.SaveAs strNewName, wdFormatDocument
End Sub

0
 
William ElliottSr Tech GuruCommented:
where strvariable is the "myfile" name

ActiveDocument.SaveAs FileName:=strvariable & ".doc", FileFormat:= _
        wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
        True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
        False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False
0
 
GrahamSkanRetiredCommented:

Write your macro like this:

Sub MyFileSave()
    Dim strName As String
    Dim strStem As String
    Dim strNewName As String
   
    strName = ActiveDocument.Name
    strStem = Split(strName, ".")(0)
    strNewName = strStem & ".rtf"
    ActiveDocument.SaveAs strNewName, wdFormatRTF
End Sub
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.