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

Populate a template in Word from Extra

Status
Not open for further replies.

Chinacat55

Technical User
Jan 9, 2007
9
CA
Good day,

I'm writing a macro in Extra to pull data from Extra and input it to specific fields in Word. So far I have collected the data as Strings and opened the Word doc. I'm having trouble specifying the location in Word where I want the data to go.

In this example, I want to put sCustdata(1) into the Word field that begins at page 1, line 8, column 14. Is there a way to specify this location?

I have searched this forum but I haven't been able to find this.

Thanks in advance for any assistance. This forum has been extremely helpful.

*********************************************************
' Declare Object Variables
Dim objApp As Object
Dim objDoc As Object
Dim objRange As Object
Dim oElements As Object
Dim objDoc1 As Object
Dim MyPage AS Object
Dim MyOutput$
Dim sCustdata(1) As String
Dim MyScreen As Object

Set MyScreen = Sess0.Screen

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
sCustdata(1) = MyScreen.GetString(7,21,10) 'Extra TXN #
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

On Error Resume Next

Set objApp = GetObject(, "Word.Application.8")

If objApp Is Nothing Then

Set objApp = CreateObject("Word.Application.8")

If objApp Is Nothing Then Exit Sub

End If

objApp.Visible = True

set objdoc= objapp.Documents.Open("C:\Documents and Settings\ALLUSER\Desktop\backscan_coversheet.doc")

End Sub
********************************************************
 




Hi,

Lines are properties of RECTANGLES in Word.

Columns are properties of TABLES in Word.

So are you refering to a TABLE object, ROW & COLUMN?

Also check out the FormFields Collection. You just might be referring to FormField, FormFields(n).

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
I did a little more research and discovered the fields in Word are named. The field I want to populate with my sCustdata(1) string is called text3.

almost there........
 


Code:
ActiveDocument.FormFields("text3") = sCustdata(1)


Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Thanks for the reply Skip. This looks like it should work but I'm getting no output in Word. I've tested to make sure I'm getting the string from Extra and that's ok. Can you see something I might be missing? I've included the line of code you provided, changed for my active app.....

*********************************************************
' Declare Object Variables
Dim objApp As Object
Dim objDoc As Object
Dim objRange As Object
Dim oElements As Object
Dim objDoc1 As Object
Dim MyPage AS Object
Dim MyOutput$
Dim sCustdata(1) As String
Dim MyScreen As Object

Set MyScreen = Sess0.Screen

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
sCustdata(1) = MyScreen.GetString(7,21,10) 'Extra TXN #
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

On Error Resume Next

Set objApp = GetObject(, "Word.Application.8")

If objApp Is Nothing Then

Set objApp = CreateObject("Word.Application.8")

If objApp Is Nothing Then Exit Sub

End If

objApp.Visible = True

set objdoc= objapp.Documents.Open("C:\Documents and Settings\ALLUSER\Desktop\backscan_coversheet.doc")

objdoc.FormFields("text3") = sCustdata(1)

End Sub
********************************************************
 


Is there an error message? The answer is YES!
Code:
objdoc.FormFields("text3")[b].result[/b] = sCustdata(1)

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
That's it Skip!!! You are the very best. Thanks for all of your help.
 
Hi, one more question on this.

I'm trying to check of a check box on the same form. I tried

objdoc.FormFields("checkWD").result = checked

and many other variations of that. Any thoughts out there....?
 





Did you try checking Word VBA help?

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top