473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Closing A Word Document Without Saving Changes In VB6

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
2 9371
Killer42
8,435 Expert 8TB
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
Thanks much!
Jan 23 '07 #3

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

Similar topics

1
by: moelleni | last post by:
Hi, I made an Access 2002 Database and wanted to automate it to sent the current record to Word 2002. So readed the article "How to send the current record to Word 2000 with automation" I tried...
2
by: Steve | last post by:
I'm using Visual Studio .NET (not 2003), and am developing a class that works with Word theough the Office PIAs (Interop). I can open word and do things with it programatically, but I can't close...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
5
by: ruomingxu via AccessMonster.com | last post by:
I am new in this area. I want to use values in a Access database and pass them to a word document. I tried this test code in a form of the Access database but it didn't work (temp.doc is a word...
1
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date...
0
by: Beta | last post by:
Does anyone know how to close an embedded word document in C# application without closing an external Word document? The issue is the external Word Document share the same instance (winword.exe)...
9
by: DeZZar | last post by:
Hi all, Basically I want the data in an open form to merge with a word template and create a new document. So a user navigates to a particular records and presses a button "Produce Document"...
1
by: mrsgwen90 | last post by:
I have an access application with a vba backend and it opens a word document to enter information and then print the word document and should close it. I keep getting an error on the line...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.