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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a help to gather text from MyExtra to Word 2002 (Easy?)

Status
Not open for further replies.

Groom84

Technical User
Feb 27, 2009
19
SE
Hi
I need some help with a macro that does following:

1: In Attachmate (MyExtra) Select words on specific fields and store them as (example) X1, next word on another specific field X2, etc.

2. Open up an existing word file on the drive and the stored information will be inserted in the (word) file and following order:
Example: The word for X1: should come after: "My name is " X1
Next row; "My adress is " X2, etc.

3.Print out the word file and close without saving.


Thanks in advance
Best Regards
Groom
 

Hi,

I'm not a Word VBA programmer, so you might need specific help for Word VBA in Forum707.

But first, you must set an application object for MS Word, using CreateObject and then open your document, using that object. Manipulating the data within MS Word, will entail using the MS Word Object Model, for which you can get help in forum707.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Groom84 - did you get your answer?

Here is the code from an Extra macro that takes fields from a screen and populates them into a Word document. I hope this helps.


' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Declare Function MyFunction()

Sub Main

call MyFunction()

End Sub

Function MyFunction()
Dim wrd As Object
Dim Session As Object
Dim System As Object
Dim MyScreen as Object

Dim TextFound as String
Dim ClientID as String
Dim FirstName as String
Dim LastName as String
Dim StreetNumber as String
Dim StreetName as String
Dim StreetType as String
Dim StreetAPT as String
Dim City as String
Dim State as String
Dim Zip as String


Set System = CreateObject("EXTRA.System")
Set Session = System.ActiveSession
Set MyScreen = Session.Screen



'Scrape the data from the host screen.

ClientID = MyScreen.GetString(4,38,9)
FirstName = MyScreen.GetString(5,13,13)
LastName = MyScreen.GetString(5,53,18)
StreetNumber = MyScreen.GetString(12,10,12)
StreetName = MyScreen.GetString(12,23,22)
StreetType = MyScreen.GetString(12,46,7)
StreetAPT = MyScreen.GetString(12,54,10)
City = MyScreen.GetString(13,7,22)
State = MyScreen.GetString(13,34,2)
Zip = MyScreen.GetString(13,43,10)

'Format the Host text to use lowercase characters

FirstName = left(FirstName,1) + lcase(right(FirstName,len(FirstName)-1))
LastName = left(LastName,1) + lcase(right(LastName,len(LastName)-1))
StreetName = left(StreetName,1) + lcase(right(StreetName,len(StreetName)-1))
StreetType = left(StreetType,1) + lcase(right(StreetType,len(StreetType)-1))
City = left(City,1) + lcase(right(City,len(City)-1))


'Insert the host information into the MS Word document

Set wrd = CreateObject("Word.application")
wrd.Documents.Open "C:\Documents and Settings\All Users\Documents\FSET_CLASS_Attm.doc"
wrd.Visible = True

wrd.ActiveDocument.CustomerName.Caption= Trim(FirstName) & " " & LastName
wrd.ActiveDocument.CustomerAddress.Caption= Trim(StreetNumber) & " " & Trim(StreetName) & " " & Trim(StreetType) & Trim(StreetAPT)
wrd.ActiveDocument.CityStateZip.Caption= Trim(City) & ", " & Trim(State) & " " & Zip
wrd.ActiveDocument.Today.Caption= format (DATE, "mmmm dd, yyyy")
wrd.ActiveDocument.ClientID.Caption= Trim(ClientID)


Set wrd = Nothing
end Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top