VBScript, Word, Printing and (not) saving.

G

Gemma M

Hi,

I have a VBScript which runs up Word on a file, allowing the user to print
it. However, when they print the document, on exit, it causes the "Do you
want to save changes to document?" message to appear.

This I do not want.

I only want the "Do you want to save changes..." message box when the user
has actually made changes, no when all he has done is printed the document,
before closing.

Can I, from VBScript, prevent the document-print operation from causing a
saveable change to the document?

Gem
 
M

McKirahan

Gemma M said:
Hi,

I have a VBScript which runs up Word on a file, allowing the user to print
it. However, when they print the document, on exit, it causes the "Do you
want to save changes to document?" message to appear.

This I do not want.

I only want the "Do you want to save changes..." message box when the user
has actually made changes, no when all he has done is printed the document,
before closing.

Can I, from VBScript, prevent the document-print operation from causing a
saveable change to the document?

Gem

Programmatically turn off warning messages in MS Office applications
http://www.a1vbcode.com/vbtip.asp?ID=66

Application.DisplayAlerts = wdAlertsNone

Global Const wdAlertsAll = -1
Global Const wdAlertsMessageBox = -2
Global Const wdAlertsNone = 0

http://www.progresstalk.com/printthread.php?t=25614
 
G

Gemma M

Hi,

Thanks for this, but I already tried it, and it doesn't work. Word is
obviously fooled into thinking that something within the document is changed
when it is printed, but whatever the something is, I cannot find it. There
are no PrintDate fields.

So, I am still at a loss.

The other thing I have found is that if I open the document read-only, then
there is no "Do you want to save changes..." message after a print.
However, if a user genuinely has changed the document, when he closes it, he
gets the "Save as..." dialogue, and we don't want users saving the document
under different names (in fact, when I run Word, I make "Save As..."
invisible on the menu).

So, I'm stuck between a rock and a hard place currently, and it's an
uncomfortable place to be, I can tell you.

Gem
 
S

Steve Yandl

I've used what follows in a few scripts. oWd is my Word Application object.

oWD.ActiveDocument.Close wdDoNotSaveChanges
oWD.Quit
Set oWD=Nothing


Steve
 
G

Gemma M

Thanks Steve,

Unfortunately, what is happening is VBScript is opening the document in Word
and then allowing the user to close it when he has finished with it (after
printing it, etc). So, once Word is running, VBScript has not control over
what is happening. But the users do not consider printing a document as
changing it, so they are confused about the save-changes message.

However, I think I may have found out the problem. In some documents, the
Document.BuiltinDocumentProperties.Item(10) contains a valid LastPrintedDate
value, and some do not. If I can make that date invalid, then Word will
neglect to update it when the document in printed.

So, does anyone know how to make the "Last Printed Date" built-in property
invalid, so that printing the document does not update it? (I might post
this as a new query)

Gem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top