![]() |
| The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum. |
|
Post Reply
|
| Author | |||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
Topic: ObjectBridgePosted: 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 |
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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:
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 |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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:
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:
Then I can either invoke an ApplyListTemplate method:
Or I can get the ListTemplate property:
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
|
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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:
There is no return value from the ApplyListTemplate method, so the 4th argument in the subroutine call should be null (''). Thanks, Pete |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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:
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
|
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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:
Thanks, Pete |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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
|
|||||||
![]() |
|||||||
Jeanette
Beta Tester
Joined: August 05 2004 Location: United States Status: Offline Points: 57 |
Post Options
Thanks(0)
Quote Reply
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 |
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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:
You may need to use the same technique for the ListTemplates array. Thanks, Pete |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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 |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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:
Based on your prior post I know that I have to invoke the applylisttemplate and pass these arguments:
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 |
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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 |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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:
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:
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
Then invoke the SETRANGE and SELECT methods again, and get TEXT (just the '&&') and finally replace it:
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 |
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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 |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
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:
I can get it to copy, but it opens a new workbook. I'm doing that using:
Can you tell me how to pass the "after" part? Thanks, Jack |
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
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 |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
Posted: December 01 2006 at 1:21am |
||||||
|
Thanks Pete,
So, if I add a worksheet using:
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):
or does ObjectBridge not recognize the Paste:=xlPasteFormats either? Thanks, Jack |
|||||||
![]() |
|||||||
PSchellenbach
Admin Group
Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
Quote Reply
Posted: December 01 2006 at 3:07am |
||||||
|
Hi Jack -
No problem using xlPasteFormats, as it is a constant:
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 |
|||||||
![]() |
|||||||
JackWeydt
Newbie
Joined: August 02 2006 Location: United States Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
Posted: December 01 2006 at 4:48am |
||||||
|
Thanks Pete.
|
|||||||
![]() |
|||||||
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |