1. David Vasconcelos
  2. PowerBuilder
  3. Thursday, 27 May 2021 19:46 PM UTC

Anyone know how to reset a documents changed flag so that if a user closes word it does not prompt for save.  I have a word document that contains bookmarks for users to fill out.  At any time a user can click a button in PB that will check/validate the bookmarks to see if any of them are empty and highlight the field, this causes the document to be changed even if the user has not entered any data. So if the user in fact does not touch the document I want to be able to allow it to close with prompting save.

PB2017R3, office pro.

 

Thanks

Dave V.

Accepted Answer
Ricardo Colarina Accepted Answer Pending Moderation
  1. Thursday, 27 May 2021 21:57 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi David,

Not sure if you can use the following:

ole_word.DisplayAlerts = true
ole_word.Documents[1].Saved = true
//or ole_object.ActiveWorkbook.Saved = true
ole_word.Application.DisplayAlerts = true

 

These can just be coded in PB.  If you want this to happen when a user closes the document then put the codes in a macro.

Cheers,

Ricardo

Comment
  1. David Vasconcelos
  2. Friday, 28 May 2021 11:06 AM UTC
Thanks Ricardo, I was using the Saved to check if document had been changed but I thought it was a read only flag and could not be updated. After reading your post I gave it a try and sure enough it worked... thanks.
  1. Helpful
There are no comments made yet.
Daryl Foster Accepted Answer Pending Moderation
  1. Thursday, 27 May 2021 21:54 PM UTC
  2. PowerBuilder
  3. # 1

Hi Dave, the property you use to check for changes is Document.Saved. If that is False you will be prompted to save changes. If you set it to True it won’t prompt to save for changes. 

In your code you could probably get the value of .Saved before you process the bookmarks and then check and reset it back to that value after your code which highlights the bookmark fields.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 27 May 2021 20:52 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Dave - 

I don't know the answer, and I really hope that somebody here does - but a question about how to make Word (or Excel, or Outlook, etc.) behave in a certain way might have a better chance of being answered in an Office or Word forum. I'm not trying to discourage you from asking questions here, I'm only suggesting you seek this kind of assistance in additional, product-specific venues because as much as I dislike admitting it, we don't know everything. ;-)

Best regards,
John

Comment
  1. John Fauss
  2. Thursday, 27 May 2021 21:08 PM UTC
Can you use the Protect() method of the Document object to temporarily prevent any changes from being applied, check the document's bookmarks, then use the Protect() method a second time to remove the temporary restriction on changes?



https://docs.microsoft.com/en-us/office/vba/api/word.document.protect

  1. Helpful
  1. David Vasconcelos
  2. Friday, 28 May 2021 11:09 AM UTC
I am actually unprotecting the doc so that I can apply the highlight then adding protection back on. By doing this it causes the doucment to be changed and hense user would get prompt to save even though they did not change anything themselves. The Saved flag (mentioned above) worked.. thanks for the reply
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.