By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

Closing A Word Document Without Saving Changes In VB6

P: 4
I have written a program in VB6 that opens an existing Word document and adds some text to the top of the document before printing it. Now I want to close the document without saving the changes. This preserves the document as a "templet". However it seems that it automatically saves the document with the changes prior to closing. Below is my code. Thanks in advance for your help.

Dim strE As String
Dim objWord As Word.Application

Set objWord = New Word.Application
objWord.Visible = True
strE = "C:\Documents and Settings\User\My Documents\G.doc"


objWord.Documents.Open strE, , , True
objWord.ActiveDocument.Content.InsertBefore vbCr & "Customer #: " & List1.List(0) & vbCr & vbCr

objWord.Documents.Application.PrintOut
objWord.Documents.Close
objWord.Visible = False
Jan 23 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 5K+
P: 8,434
From the object browser, for the Word library, Document member:

Sub Close([SaveChanges], [OriginalFormat], [RouteDocument])

Also, these members of Word.WdSaveOptions look relevant...
  • Const wdDoNotSaveChanges = 0
  • Const wdSaveChanges = -1 (&HFFFFFFFF)
  • Const wdPromptToSaveChanges = -2 (&HFFFFFFFE)
Jan 23 '07 #2

P: 4
Thanks much!
Jan 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.