Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing data from Attachmate to User form in Word 1

Status
Not open for further replies.

cherbert

Technical User
Jan 31, 2013
6
NZ
Hi all,

I wonder if anyone can tell me whether it is possible to pull text from an Extra! session (using, for example, getstring) and then pass that data into a user form in word.

What I have at the moment (and which works fine) is when a client account is opened and a certain action initiated (in this case the sending of a letter), the macro performing that action determines whether the account meets certain criteria (in this case, if there is more than one nominated contact person). If there isn't all actions can be performed within the session and the macro just proceeds. If, however, there is more than one person, then the letter needs to be sent manually. Extra notifies the user of this (by way of a message box) and then launches MS Word, and adds to the word session an appropriate letter.

Separately, on opening that word file creates a new document, and opens a userform which, once completed (this is done manually), insets the entered data into the letter and launches the print dialog/ue.

I wonder, though, if it is possible for Extra to complete the userform based on datas available to it. For example, if the client name appears at 04, 25 and is 5 characters long in Extra can Extra perform getstring(04,25,05) and then auto-complete (if you will) word's (active) userform (by, for example changing the value of the particular textbox - e.g. ActiveDocument.Userform1.Textbox1.Value = "[whatever]" ).

This needs to be done from within extra, rather than on initialization of the userform as the letters are also used independently (and it would be annoying to open it, and then have it try to scrape an extra session and auto complete with data that you never wanted....)

Any help would be much appreciated!

C.
 
hi,

The short answer is "Yes."

But let me suggest another possibility, that may be useful, assuming that you have to process a list of some sort get data for each from the emulator.

Typically a list is processed from Excel to Extra and the results are written back to Excel in a TABLE.

That TABLE can be linked via MailMerge in Word to populate a form for each one in the TABLE.

Could a process like this, satisfy your requirements? It is generally much quicker in execution, but may take more programming time to accomplish.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I suspect that solution would work well for batch processing accounts, all of which require a similar action (which is a fantastic idea, and I'm sure I can find a way of implementing that!). But for processing on case-by-case basis it's probably less ideal.

The accounts are bank accounts, and the decision whether or not to send a sternly worded letter, or a gentle reminder, or a letter on solicitor's letterhead is one that's not really amenable to an automated decision (though I suppose the alternative that implements your solution is to apply some code to each account and then just batch process at the end of the day when you have a list). It would, however, be more ideal to do each account individually as the situation arises.

Perhaps an alternative (and much easier, I suspect) solution is just inserting a button into the userform to scrape the data from Extra when required. If my earlier suggestion is not too onerous to explain (or even if you could point me in the vaguely right direction) it would be much appreciated :)

C
 
Relatedly,

the names in extra display as Jane M +Doe. Whereas In other circumstances when I've had to employ data in excel it has been easy enough to pass the entire string "Jane M + Doe" into a single cell, and then convert text to columns using " " and "+" as delimiters so I end up will cells containing the first name, initial and last name (less the +).

Is there a way to do this in extra (so it gets the string from a given coordinate to a space character, or gets a string from a + through to a space character? (though I imagine this could be executed by scanning for a +, moving one character left, and then getting the string up to the space as above).

This is probably not the most appropriate place for this particular post...

C
 
Well if you think that you might want to do either the onesie or list process on demand, then one way to design the process might be to either 1) have a list of 1 or 2) the means to step thru the list one at a time or 3) process the list as a batch. In any case, the process would start from a list with some sort of control to regulate how the list is to be processed.

Otherwise, do the scrape and put as you have conceived.

I personally dislike Extra VB and the editor. I'd rather drive a Lincoln than a Pinto. So do ALL my screen scrape coding in Excel VBA, since that is my starting and ending application. You might consider using Word or Excel VBA and adding a reference in Tools > References in the VBA Editor to the Attachmate Extra! n.m Object Library. Frankly, I can help you with the general framework of code in Word VBA, but I have very little experience with Word Object and Word application features. That's where the MailMerge feature come in to help me out. That's why I suggested even a one at a time to write to an Excel Table that MailMerge can process.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Will give it a shot using mail merge and see how I get on

Thanks Skip! :)
 
Ar far as scraping between certain coordinates and a given character, any tips on how to do that?

Given that I'll use excel to generate a table to use in the mail merge I can use the method I described above (text to columns), but it would skip a step if extra could just do that for me (and reduce the chance of errors.

C
 
SOLVED!

Should someone ever venture across this...

Solution was to use Extra! to launch Word (& the userform as part of the open document procedure). As part of the initiate procedure of the userform, excel launches (though not visibly), the open procedure of the excel document pulls all the required data from Extra! Word is then re-activated and pulls all the data from excel. Then excel closes (and no one is any the wiser as to what happened...).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top