1. David Vasconcelos
  2. PowerBuilder
  3. Wednesday, 14 April 2021 14:55 PM UTC

Using ole and opening a document in word, is it possible for Word to call a function/event back to Powerbuilder.

I would like be able to check to see if a field/bookmark was filled in. (I am sure it can be done in a macro or vb script) but was wondering if it was possible to communicate back to Powerbuilder to allow PB to check.

Thanks

Dave V.

 

Environment.

Powerbuilder 2017, R3, windows 10, Word (office 365 pro plus)

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 14 April 2021 19:52 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi David;

  Yes, in an MS-Word macro with VBScript, you can use the FindWindow() SDK command  to locate any active PB App's window class. Then use the MS-Windows SendMessage() SDK command to send a message to your PB App's window remembering that User Events can be triggered as Message #1024 for "Custom01" through Message #1099 for "Custom75".

Example: http://stackoverflow.com/questions/60275513/can-we-call-windows-api-functions-in-vbscript?noredirect=1&lq=1

 Upon receipt of the UE, your PB App can then know that the MS-Word action was completed and whether is was successful as well.

HTH  ;-)

Regards ... Chris

Comment
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Thursday, 15 April 2021 02:31 AM UTC
  2. PowerBuilder
  3. # 1

Hi Dave,

If I understand correctly what you're trying to do it sounds like you have two approaches...a push approach or a pull approach. Chris' suggestion, which is an interesting approach, is what I'd call a push approach where you're trying to push some information or communicate from MS Word to PB.

The pull approach would be trying to pull that information from MS Word using PB. Any reason why you wouldn't just connect to that document from PB and, via properties/ methods of MS Word object model, check whether those fields/ bookmarks were filled in? This could be done for a bookmark using something like...

ls_bookmark_value = My_Ole_Word.ActiveDocument.Bookmarks.item("BOOKMARKNAME").Range.Text

...and compare that to whatever the default value is when a bookmark is not filled in yet.

Again, maybe with your use case you need to have that initiated from MS Word and so this may not work for you.

HTH...regards,

Mark

Comment
  1. David Vasconcelos
  2. Thursday, 15 April 2021 11:21 AM UTC
Thanks Chris and Mark, Mark I already knew about getting info from bookmarks but wanted to cover all my basis. The document is live so we do pass info to bookmarks on the document but there are also fields on it that we do not save, they only exist on the document. So I was checking to see if there was a way that when the document is saved or closed to run validations on those fields. Based on Chris's response I now know that it is possible to do call to PB from Word, so just need to find out what the client wants to do.
  1. Helpful
  1. Mark Goldsmith
  2. Thursday, 15 April 2021 13:13 PM UTC
Understood Dave, thanks for the follow-up.

Regards,

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