Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Speichern Dialog trotz Setzen von ActiveDocument.Saved=True

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Armin Laschet - 24 Aug 2005 12:16 GMT
Hallo,

arbeite mich seit drei Wochen unter Win2000/Office2000 in VBA ein.

Ich habe ein Word-Dokument erstellt mit Feldern (Links). Dazu die
beiden Prozeduren:

Private Sub Document_Open()
Dim fld As Field

   ' Hier soll noch eine Überprüfungsroutine rein,
   ' an deren Ende dann entschieden wird,
   ' ob aktualisiert werden soll oder nicht

   For Each fld In ActiveDocument.Fields
       If fld.Type = wdFieldLink Then
           fld.Update
       End If
   Next fld

   ActiveDocument.Saved = True
End Sub

Private Sub Document_Close()

  Debug.Print ActiveDocument.Saved   ' = 'False'

End Sub

Damit aktualisiere ich die Felder 'manuell' und setze 'Saved' auf
'True', damit der "Speichern"-Dialog beim Schließen nur dann
hochkommt, wenn (weitere) Änderungen am Dokument vorgenommen wurden.
Seltsamerweise kommt er aber immer hoch ('Saved' ist in
Document_Close() 'False'). Mit OfficeXP erhalte ich dasselbe Ergebnis.
Weiß jemand, warum das so ist und/oder was ich machen muss, um den
erwünschten Effekt zu erzielen?

Armin
Jezebel - 24 Aug 2005 22:35 GMT
Entschuldigung daß ich nicht auf Deutsch antworten kann.

Clearly something else is modifying the document and setting Saved to false.
Printing the document will do it; as will the inclusion of any self-updating
fields (like DATE). After the document opens and your Document_Open macro
has run, switch to VBA and check the value of Saved.

Hallo,

arbeite mich seit drei Wochen unter Win2000/Office2000 in VBA ein.

Ich habe ein Word-Dokument erstellt mit Feldern (Links). Dazu die
beiden Prozeduren:

Private Sub Document_Open()
Dim fld As Field

   ' Hier soll noch eine Überprüfungsroutine rein,
   ' an deren Ende dann entschieden wird,
   ' ob aktualisiert werden soll oder nicht

   For Each fld In ActiveDocument.Fields
       If fld.Type = wdFieldLink Then
           fld.Update
       End If
   Next fld

   ActiveDocument.Saved = True
End Sub

Private Sub Document_Close()

  Debug.Print ActiveDocument.Saved   ' = 'False'

End Sub

Damit aktualisiere ich die Felder 'manuell' und setze 'Saved' auf
'True', damit der "Speichern"-Dialog beim Schließen nur dann
hochkommt, wenn (weitere) Änderungen am Dokument vorgenommen wurden.
Seltsamerweise kommt er aber immer hoch ('Saved' ist in
Document_Close() 'False'). Mit OfficeXP erhalte ich dasselbe Ergebnis.
Weiß jemand, warum das so ist und/oder was ich machen muss, um den
erwünschten Effekt zu erzielen?

Armin
Armin Laschet - 24 Aug 2005 23:18 GMT
Hi Jezebel,

sorry that I posted in German in the first place.

The fields I inserted are three links to cells in an excel-sheet.
Nothing self-updating here. There's nothing else in the document.
'Saved' stays 'True' till the end of Document_Close(). Then the "Save
Changes?" dialog comes up.
In my deep dispair :) I even threw in an
ActiveDocument.AcceptAllRevisions before ActiveDocument.Save = True in
the Open procedure - to no avail.

Next thing I removed the for-each-loop and activated 'auto link update
on opening document' under options - general - to no avail.

Any further suggestions?
Klaus Linke - 25 Aug 2005 10:44 GMT
Hi Armin,

Not sure if there's a better, "proper" way to do it.
If you don't find anything, you might try the code below which uses SendKeys
(yukk!) to cancel out of the message box that pops up. I posted it here last
week to a similar question.

Regards,
Klaus

Sub AutoClose()
 Dim myDoc As Document
 Set myDoc = ActiveDocument
 Application.EnableCancelKey = wdCancelDisabled
 If ActiveDocument.Saved = False Then
   Select Case _
   MsgBox("Do you want to save the changes?", _
   vbQuestion + vbYesNoCancel, _
   myDoc.Name)
     Case vbYes
       ' Dialogs(750).Show
       myDoc.Save
       myDoc.Close
     Case vbNo
       myDoc.Saved = True
       myDoc.Close
     Case vbCancel
       SendKeys "{ESC}"
   End Select
 Else
   myDoc.Close
 End If
 Application.EnableCancelKey = wdCancelInterrupt
End Sub

> Hi Jezebel,
>
[quoted text clipped - 12 lines]
>
> Any further suggestions?
Armin Laschet - 25 Aug 2005 11:36 GMT
Hi Klaus,

thanx for your detailed suggestion. I was already given a hint to
SendKeys yesterday by someone who referred to your posting (I guess; hi
Helmut ;) ).

I will check it, when I'm home from work. But it looks pretty yukky to
me, too. Amazing, that there seems to be no clean way to do it.
Thought, that what I intend to do is just an everyday-task.

Have a nice day

Armin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.