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 / June 2007

Tip: Looking for answers? Try searching our database.

detect if Word has been edited

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Terry - 07 Jun 2007 00:29 GMT
Hi,

I am opening word via VB (code below) and need to know if the user has made
any edits to the doc.
I know I can use wordbasic.isdocumentdirty() in a VBA as below,

Private Sub Document_Close()
If WordBasic.IsDocumentDirty() Then
   MsgBox "Doc is dirty"
Else
   MsgBox "Doc is not dirty"
End If
End Sub

But I do not want to use a VBA module within the Word doc if I can avoid it.

Is there a way for the calling VB exe to determine IsDocumentDirty() ?
VB code follows:

Dim objApp As New Word.Application
Dim objDoc As Word.Document

   objApp.Documents.Open FileName:="C:\temp\test.doc",
AddToRecentFiles:=False

       objApp.Visible = True
       objApp.Activate
   Set objDoc = objApp.ActiveDocument

MsgBox "Click to continue"
objDoc.Close
Andrew Kennard - 07 Jun 2007 17:57 GMT
Check the Saved property for the active document

If it's True the document is NOT dirty

HTH

Andrew

> Hi,
>
[quoted text clipped - 28 lines]
> MsgBox "Click to continue"
> objDoc.Close
kozaw - 08 Jun 2007 06:41 GMT
> Check the Saved property for the active document
>
[quoted text clipped - 36 lines]
> > MsgBox "Click to continue"
> > objDoc.Close

Yes, it is as simple as..

Private Sub CheckingDocSavedOrNot()
If Activedocument.saved = False Then
  MsgBox "Doc is dirty"
 ' you can do saving by >>  Activedocument.save
Else
  MsgBox "Doc is not dirty"
End If
End Sub

KoZaw
 
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.