?
Solved

Using MS Word FileSaveAs macro from the command line.

Posted on 2007-08-01
3
Medium Priority
?
858 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:chigh
  • 2
3 Comments
 
LVL 19

Expert Comment

by:weellio
ID: 19613404
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 19613776

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
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1000 total points
ID: 19613792
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question