Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Word 2003 Macro Help

Oct 5, 2007 4:59AM PDT

Hello,

I'm not finding what I need or not sure of what I really need to look for.

What I am trying to do is, call "winword /mSaveAsHTML sometextfile.txt" from a bat file. I want it to automatically open the text file and do a save as to create an HTML version of the file, then automatically close Word. I tried to record a macro and can get the save as portion, but the close document and exit Word part I'm not sure how to accomplish. Is there a way to do this?

Thanks.

Discussion is locked

- Collapse -
Available on Google
Oct 5, 2007 6:07AM PDT

I found a lot of options using;

Word VBA, how to quit Word.

But this may help;

Sub CloseAll()
'Close all open files and shutdown Word

With Application
.ScreenUpdating = False

'Loop Through open documents
Do Until .Documents.Count = 0
'Close no save
.Documents(1).Close SaveChanges:=wdDoNotSaveChanges
Loop

'Quit Word no save
.Quit SaveChanges:=wdDoNotSaveChanges
End With
End Sub


Mark

- Collapse -
Word 2003 Macro Help
Oct 19, 2007 3:46AM PDT

ActiveDocument.Save
Application.Quit