Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Advanced Features
  New Posts New Posts RSS Feed - ObjectBridge
  FAQ FAQ  Forum Search   Register Register  Login Login

The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum.

Forum LockedObjectBridge

 Post Reply Post Reply
Author
Message
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Topic: ObjectBridge
    Posted: August 04 2006 at 8:10am

Hi Pete,

 

I am currently trying to use ObjectBridge to create a new letter using MS Word but there doesn't seem to be a lot of documentation on it.  I'm looking to bold some of the text, center some text and bullet point some text.

Selecting the text was already written in your sample application 'CREATE.WORD.LETTER' , so that was great.

 

I assume I'd use the ATINVOKEMETHOD or the ATSETPROPERTY to set the selection properties to bold/center/bullet but I have no idea where to find the correct arguments to pass.

 

All of the 'ATGUI' subroutines have wonderful explanations for all the arguments passed and even what can be passed.

 

Do you have any guidance on these methods?

 

Jack

Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: August 06 2006 at 4:15am
Hi Jack -

ObjectBridge provides a generic mechanism to access an Automation-enabled Windows application. Since it is generic in nature, there is no specific documentation for any of the target application properties or methods.

When trying to automate Word (or any Office app), the easiest way to figure out what properties or methods you need to use is to use Word itself and record a macro. Then open the recorded macro in the VBA editor and examine what was recorded. Its not too difficult to translate the VBA from the macro into ObjectBridge calls. Note that in Word, many constants have names, but you should be able to right-click the constant and choose Definition to see its value. Also, VBA lets you build compound object expressions, like:
Selection.Font.Italic = wdToggle

In this example, the Selection object has a Font property that returns a Font object, which has an Italic property that you can toggle. With ObjectBridge, you need to get the Font property (object) from the Selection object using ATGETPROPERTY, then set the Italic property of the Font object using ATSETPROPERTY. In this example, wdToggle is a constant with the value of 9999998.

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: August 11 2006 at 3:19am

Thanks Pete.

I've formatted all of my text and even added an image to the letterhead.  Now I'm stuck on the bullet points.
 
I'm trying to put in the standard round bulletpoint.  The VBA code for it is:
 
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:=
wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior
 
I've tried to add bullet points a few different ways and I keep getting errors.  Here's what I've tried;
 
First I get the list format property from the range object:
 
CALL ATGETPROPERTY(RNG.OBJ, 'LISTFORMAT', LST.OBJ, ERRMSG, OPTS)
 
Then I can either invoke an ApplyListTemplate method:
 
CALL ATINVOKEMETHOD(LST.OBJ,'APPLYLISTTEMPLATE','',TP.OBJ,ERRMSG,OPTS)
 
Or I can get the ListTemplate property:
 
CALL ATGETPROPERTY(LST.OBJ,'LISTTEMPLATE',TP.OBJ,ERRMSG,OPTS)
 
From here all I get is an error "Invalid procedure call or argument".
I've tried numerous variations of GET, SET and INVOKE and just can't seem to get any other response.
 
Thanks for any help.
 
Jack
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: August 16 2006 at 9:32am
Hi Jack -

Looks like you are going to need several steps to set bullet points!

Looking at the code from the Word macro recroder, you are going to need to get the ListFormat object from the Range object from the Selection object. Now, on the right side of the equal sign, you need a ListTemplate object which you get from the ListGalleries (array) object using the ListTemplates (array) property.

Your code to obtain the ListFormat object looks correct. Before you call the ApplyListTemplate method on the ListFormat object, you need the template object.

You can get a ListGallery object from the Word Application object (WD.OBJ in the CREATE.WORD.LETTER sample program) via the ListGalleries() array property, using array index of 1 (wdBulletGallery). Then get the ListTemplate object using the ListGallery object's ListTemplates() array property, again using index 1.

Finally, your call to ATINVOKEMETHOD is almost correct: you need to pass the method arguments in the 3rd subroutine argument, like:
ARGS=TP.OBJ:VM:0:VM:0:VM:2

There is no return value from the ApplyListTemplate method, so the 4th argument in the subroutine call should be null ('').

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: August 17 2006 at 8:22am

Thanks for responding Pete.

I think the problem I'm having is with the ListGalleries "array" and the ListTemplates "array".  How exactly do I access them?
 
I've gotten the word, selection, range and listformat objects.  I have been able to get the listgalleries object.  but from there I can't do anything.
 
Here's what I have so far:
 
CALL ATGETPROPERTY(PAR.OBJ, 'RANGE', RNG.OBJ, ERRMSG, OPTS)
CALL ATGETPROPERTY(RNG.OBJ, 'LISTFORMAT', FMT.OBJ, ERRMSG, OPTS)
CALL ATGETPROPERTY(WD.OBJ, 'LISTGALLERIES', GALS.OBJ, ERRMSG, OPTS)
 
Now no matter what I try with GALS.OBJ, I get "Object doesn't support this property or method".
How do I pass the correct index (1)? The ATGETPROPERTY/ATSETPROPERTY don't look like they allow me to pass the index number.
 
Again, thanks for all your help Pete.
Jack
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: August 17 2006 at 9:22am
Hi Jack -

To pass an index to an array property, concatenate the property name, a SVM, and the index. For example:
CALL ATGETPROPERTY(WD.OBJ,'LISTGALLERIES':SVM:1,GALS.OBJ,ERRMSG,OPTS)

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: August 18 2006 at 1:44am
Thanks very much Pete.
 
I hate to do this to you, but I get an error on that, too.
 
Now it says " 'Item' is not a property."
 
Jack
Back to Top
Jeanette View Drop Down
Beta Tester
Beta Tester


Joined: August 05 2004
Location: United States
Status: Offline
Points: 57
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jeanette Quote  Post ReplyReply Direct Link To This Post Posted: August 18 2006 at 2:59am
Hi Jack! I have used a slightly different approach to your probelm. What we do is have a 'template' word document in rtf format. This template basically is a predefined document with the name of the field like this:

Dear <<name>>

Then we use super q pointers to the folder where the template lives and we run a program that finds all the <<name>> and replaces it with the actual name. The file is then automatically saved with a new name we have given it - normally doen with a 'nextno' counter in the dictionary.

This is way simpler than what you are trying to do.

Jeanette
www.mindsview.com
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: August 18 2006 at 11:05am
Hi Jack -

I did some experimenting and found that Item is a method of ListGalleries, not a property. Looks like a property in the object browser. So, you need to get the ListGalleries object, then invoke the Item method, using 1 as the method arguments:
CALL ATGETPROPERTY(WD.OBJ,'LISTGALLERIES',GALS.OBJ,ERRMSG,OPTS)

IF ERRMSG NE '' THEN PRINT ERRMSG; CALL ATRESETOBJMGR
CALL ATINVOKEMETHOD(GALS.OBJ,'ITEM',1,GAL.OBJ,ERRMSG,OPTS)
IF ERRMSG NE '' THEN PRINT ERRMSG; CALL ATRESETOBJMGR


You may need to use the same technique for the ListTemplates array.

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: August 21 2006 at 4:18am

Thanks Jeanette,

 

This is a great idea.  What I did is save the letter as a template on the network.  And set up sort of a "mail merge" type routine.  I use the ATGETPROPERTY to get each paragraph, then I loop through each word looking for '&&', al la 4-Word.  I then replace '&&' with the next word in my variables list and use ATSETPROPERTY to replace the paragraph.

 

Basically I'm doing as you suggested, without the super q pointers.

 

This method works great except for one thing, fjarr also had a problem with in a post back in November '05 (no reply to his post tho).  The ATSETPROPERTY changes single and double quotes to question marks.  These are the only characters I've seen a problem with so far.

 

Any ideas about that?

 

Thanks again.

 

Jack

Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: August 21 2006 at 4:38am

Thanks Pete.

 

As you can see from my reply to Jeanette, I've gone a different way with this.  However, I'd still like to make this work.  I hate to walk away from something unfinished.

 

Here's what now works:

 

CALL ATINVOKEMETHOD(RNG.OBJ, 'SELECT', '', '', ERRMSG, OPTS)

CALL ATGETPROPERTY(RNG.OBJ, 'LISTFORMAT', FMT.OBJ, ERRMSG, OPTS)

CALL ATGETPROPERTY(WD.OBJ,'LISTGALLERIES',GALS.OBJ,ERRMSG,OPTS)

CALL ATINVOKEMETHOD(GALS.OBJ,'ITEM',1,GAL.OBJ,ERRMSG,OPTS)

CALL ATGETPROPERTY(GAL.OBJ, 'LISTTEMPLATES',TMPS.OBJ,ERRMSG,OPTS)

CALL ATINVOKEMETHOD(TMPS.OBJ,'ITEM',1,TMP.OBJ,ERRMSG,OPTS)

 

Based on your prior post I know that I have to invoke the applylisttemplate and pass these arguments:

 

ARGS=FMT.OBJ:VM:0:VM:0:VM:2

CALL ATINVOKEMETHOD(FMT.OBJ,'APPLYLISTTEMPLATE',ARGS,'',ERRMSG,OPTS)

 

Now I get my first error, "Type mismatch".  Am I using the wrong objects?  I tried passing then TMP.OBJ as the first argument and got the same result.

 
As I said, this isn't critical, but seeing as I am so close to making this work, I'd really hate to give up on it.  Any ideas about this or my post to Jeanette?

 

Thanks again.

 

Jack

Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: August 21 2006 at 5:14am
Hi Jack & Jeanette -

First, the problem of quote marks being changed is due to character set conversions. When you get the paragraph text using ATGETPROPERTY, the actual paragraph text is retreived in Unicode by the ObjectBridge on the PC. Then the Unicode text is converted into the 8-bit host character set using either codepage 437 (Wyse/ADDS emulations) or codepage 1252 (VTxxx emulations). The 8-bit host character set does not have characters for the start & end quote characters, only the old ASCII single and double quotes.

As an alternative to using ObjectBridge for this project, have you seen the article on using Mail Merge with MV data and Word? Here's a link in case you are interested.

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: August 21 2006 at 8:16am
Thank you (yet again) Pete!
I actually figured out a way around this little problem. 
First, I've already selected the paragraph using:
PROPS = 'START' :AM: 'END'
CALL ATGETPROPERTY(RNG.OBJ, PROPS, VALUES, ERRMSG, OPTS)
SP = VALUES<1>; EP = VALUES<2> - 1
ARGS = SP :VM: EP
CALL ATINVOKEMETHOD(RNG.OBJ, 'SETRANGE', ARGS, '', ERRMSG, OPTS)
CALL ATINVOKEMETHOD(RNG.OBJ, 'SELECT', '', '', ERRMSG, OPTS)
TEXT = ''
CALL ATGETPROPERTY(RNG.OBJ, 'TEXT', TEXT, ERRMSG, OPTS)

All code I assume you wrote in the CREATE.WORD.LETTER sample?
Since I now know what the starting point of the paragraph is, I can then, in Pick, figure out where the '&&' is with:
N = INDEX(TEXT,'&&',1)

Then I can add the start position of the paragraph to the start position of the '&&' (in Pick) to give me the start position of the '&&' in "TEXT".
Then I just retrace those steps using the new start and end positions
A1 = N+SP - 1;* subtract 1 to get 1st position
A2 = A1 + 2; * add two to cover both '&&'

Then invoke the SETRANGE and SELECT methods again, and get TEXT (just the '&&') and finally replace it:
TEXT = (replacement text)
CALL ATSETPROPERTY(RNG.OBJ, 'TEXT', TEXT, ERRMSG, OPTS)

 
Will the mail merge be faster?  If so I can take a look at it, but I had most of this code written and I want to get this project out to the users.  I can always speed it up for them later.
 
Thanks for all of you help. 
 
Jack
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: August 21 2006 at 9:45am
Hi Jack -

I think the mail merge is faster, because there is really no interactive communication between the host and Word. You use one of the file transfer routines to send the variable data to the PC, then use a script, which runs on the client side, to perform the mail merge. Its really quite efficient.

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: November 29 2006 at 2:16am
Hello Pete,

I'm working on a new project and I'm using ObjectBridge once again.

I'm opening a template workbook and trying to copy the template worksheet and add my data to the copy. I'll then delete the template worksheet and invoke 'SaveAs' to a new workbook name.

It's the "copy after" that I'm having trouble with, everything else works fine. The VBA code is:

Sheets("name").Copy After:=Sheets(1)


I can get it to copy, but it opens a new workbook. I'm doing that using:
CALL ATINVOKEMETHOD(Worksheets, 'COPY', '', '', ERRMSG, OPTS)


Can you tell me how to pass the "after" part?

Thanks,

Jack
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: November 30 2006 at 9:00am
Hi Jack -

Looks like the Copy method is not compatible with ObjectBridge. First, ObjectBridge does not support "named arguments" (as in After:= in the VBA code). ObjectBridge also does not support missing arguments - you cannot specify an argument for After unless you include one for Before, but the Excel object model documentation says you cannot specify After if you specify Before. Finally, the Before and After arguments are objects. The problem here is that ObjectBridge does not have any way to distinguish between an integer and an object.

Thanks,

Pete
Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: December 01 2006 at 1:21am
Thanks Pete,

So, if I add a worksheet using:
CALL ATINVOKEMETHOD(Worksheets, 'Add', '', Worksheet, ERRMSG, OPTS)

Could I then select all the cells (haven't figured out that code yet) and copy the formatting from one sheet to the other (vba code):
Selection.PasteSpecial Paste:=xlPasteFormats


or does ObjectBridge not recognize the Paste:=xlPasteFormats either?

Thanks,
Jack
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: December 01 2006 at 3:07am
Hi Jack -

No problem using xlPasteFormats, as it is a constant:
Const xlPasteFormats = -4122

Also, since XLPasteType is the first argument in the PasteSpecial method, the others can be ignored. Even if you specify all 4 arguments, they are all constants or integers, so again, no problem.

Thanks,

Pete

Back to Top
JackWeydt View Drop Down
Newbie
Newbie


Joined: August 02 2006
Location: United States
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote JackWeydt Quote  Post ReplyReply Direct Link To This Post Posted: December 01 2006 at 4:48am
Thanks Pete.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.