JPDO
07-27-2006, 03:09 AM
Hi,
I launch MS-word from an EXCEL-application to fill-up a Word-document that i defined as a Fill-in Form .
Filling up is OK, but at the end of the document I have to insert the content of a TXT-file and that gives me a runtime error 438.
What did I wrong?
Here goes my coding:
wdModelCLFullname = "S:\AS_400\JPDO\kwitluxfr-temp.doc"
Set wdApp = Nothing
Set wdDoc = Nothing
' ---------------------------------------
' * Open Word
' ---------------------------------------
Set wdApp = New Word.Application
Set wdDoc = New Word.Document
Set wdDoc = wdApp.Documents.Add(wdModelCLFullname, False, wdNewBlankDocument, True)
wdDoc.Activate
wdApp.Visible = True
wdDoc.Unprotect
wdDoc.FormFields("NM1").Result = NM1
wdDoc.FormFields("REFN1").Result = REFN1
' ---------------------------------------
' * Form FIELD TEXT1 is the location where i want to insert the TXT-File
' ---------------------------------------
wdDoc.FormFields("TEXT1").Select
wdDoc.FormFields("TEXT1").Delete
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.InsertParagraphAfter
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.Select
With Selection
.InsertFile Filename:="C:\download\KWITLUXFR.txt", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End With
MsgBox "Save Your Document now"
Thanks for any reply.
I launch MS-word from an EXCEL-application to fill-up a Word-document that i defined as a Fill-in Form .
Filling up is OK, but at the end of the document I have to insert the content of a TXT-file and that gives me a runtime error 438.
What did I wrong?
Here goes my coding:
wdModelCLFullname = "S:\AS_400\JPDO\kwitluxfr-temp.doc"
Set wdApp = Nothing
Set wdDoc = Nothing
' ---------------------------------------
' * Open Word
' ---------------------------------------
Set wdApp = New Word.Application
Set wdDoc = New Word.Document
Set wdDoc = wdApp.Documents.Add(wdModelCLFullname, False, wdNewBlankDocument, True)
wdDoc.Activate
wdApp.Visible = True
wdDoc.Unprotect
wdDoc.FormFields("NM1").Result = NM1
wdDoc.FormFields("REFN1").Result = REFN1
' ---------------------------------------
' * Form FIELD TEXT1 is the location where i want to insert the TXT-File
' ---------------------------------------
wdDoc.FormFields("TEXT1").Select
wdDoc.FormFields("TEXT1").Delete
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.InsertParagraphAfter
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.Select
With Selection
.InsertFile Filename:="C:\download\KWITLUXFR.txt", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End With
MsgBox "Save Your Document now"
Thanks for any reply.