Saving changes 
Author Message
 Saving changes

Hello,

I use the following code to retrieve some document statistics of a document.

Dim doc As Document
Set doc = GetObject(N$) 'N$ is the full path name of a document
A$ = doc.BuiltInDocumentProperties(wdPropertyWords)
doc.Close savechanges:=wdDoNotSaveChanges

When the code is run, however, it turns out that I was still prompted for
saving changes to the document.
What went wrong? Suggestions are most welcome!



Sun, 01 Aug 2004 20:03:54 GMT  
 Saving changes
Even looking at the document properties of an open document sets the marker
in Word that the document has been changed. This is true even if one cancels
to close the dialog box.

What happens if you set doc.close savechanges:=False?

Otherwise, you may want to explore accessing the document properties without
opening the document. This involves installation of a .dll and is explored
in depth on the MVP website in the VBA FAQ.
--
Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
 --------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


Quote:
> Hello,

> I use the following code to retrieve some document statistics of a
document.

> Dim doc As Document
> Set doc = GetObject(N$) 'N$ is the full path name of a document
> A$ = doc.BuiltInDocumentProperties(wdPropertyWords)
> doc.Close savechanges:=wdDoNotSaveChanges

> When the code is run, however, it turns out that I was still prompted for
> saving changes to the document.
> What went wrong? Suggestions are most welcome!



Sun, 01 Aug 2004 21:42:22 GMT  
 Saving changes
Hi Robot,

You don't need the line
doc.Close SaveChange:=wdDoNotSaveChanges
because you aren't opening the document; you're just accessing it.
Try

Dim doc As Document
Set doc = GetObject(n$) 'N$ is the full path name of a document
a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
Set doc = Nothing

If the document is already open (for whatever reason), then you can use
Dim doc As Document
Set doc = GetObject(n$) 'N$ is the full path name of a document
a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
Set doc = Nothing
Documents(n$).Saved = True
Documents(n$).Close

HTH

Quote:
> Hello,

> I use the following code to retrieve some document statistics of a
document.

> Dim doc As Document
> Set doc = GetObject(N$) 'N$ is the full path name of a document
> A$ = doc.BuiltInDocumentProperties(wdPropertyWords)
> doc.Close savechanges:=wdDoNotSaveChanges

> When the code is run, however, it turns out that I was still prompted for
> saving changes to the document.
> What went wrong? Suggestions are most welcome!



Sun, 01 Aug 2004 22:13:06 GMT  
 Saving changes
Hi Dave,

I try

Dim doc As Document
 Set doc = GetObject(n$) 'N$ is the full path name of a document
 a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
Set doc = Nothing

The code works fine until I close Word 2000, when I am still prompted for
saving changes to the document N$.

Don't know what to do next.



Mon, 02 Aug 2004 23:21:25 GMT  
 Saving changes


Quote:
> Hi Dave,

> I try

> Dim doc As Document
>  Set doc = GetObject(n$) 'N$ is the full path name of a document
>  a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
> Set doc = Nothing

> The code works fine until I close Word 2000, when I am still prompted for
> saving changes to the document N$.

> Don't know what to do next.



Mon, 02 Aug 2004 23:51:22 GMT  
 Saving changes
Hi Robot,

Try

Set doc = GetObject(n$) 'N$ is the full path name of a document
a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
doc.Saved = True
doc.Close
Set doc = Nothing

HTH

Quote:
> Hi Dave,

> I try

> Dim doc As Document
>  Set doc = GetObject(n$) 'N$ is the full path name of a document
>  a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
> Set doc = Nothing

> The code works fine until I close Word 2000, when I am still prompted for
> saving changes to the document N$.

> Don't know what to do next.



Mon, 02 Aug 2004 23:52:29 GMT  
 Saving changes

Quote:

> Hi Robot,

> Try

> Set doc = GetObject(n$) 'N$ is the full path name of a document
> a$ = doc.BuiltInDocumentProperties(wdPropertyWords)
> doc.Saved = True
> doc.Close
> Set doc = Nothing

> HTH

This works! Thank you so much!


Tue, 03 Aug 2004 00:45:36 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Save changes back to a previously saved .msg file

2. Prompt for saving changes

3. save changes on synchronisation

4. Saving Changes to Templates

5. Close oXL from Word, and don't save changes

6. Outlook 2000: Custom form - read page keeps asking for save changes

7. save changes box is not wanted

8. closing a document without saving changes

9. Not saving changes to Templates

10. No Save Changes in Template???

11. VBScript and saving changes

12. Closing a Global Template...prompt to Save Changes

 

 
Powered by phpBB® Forum Software