B
Bob S
Hi-
I'm building a custom task form (p.2 below)that has text
boxes and a command button. When I press the command
button I want the text from the text boxes (txt1, for
example)to go to certian spots on a word document
(test.doc with booksmarks). I got it to work using the
following code:
Sub CMDOpenWD_Click
Dim objWord 'As Word.Application
Dim objDoc 'As Word.Document
Dim objSelect 'As Word.Selection
Dim objDocItem 'As DocumentItem
dim control 'As outlook control
dim formpage 'As page
Set FormPage = Item.GetInspector.ModifiedFormPages("P.2")
Set control = formpage.controls("txt1")
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.open("C:\test.doc" )
Set objSelect = objWord.Selection
'msgbox objdoc.Bookmarks.count'sanity check one
objSelect.TypeText control.text
'Msgbox control.text'sanity check two
objword.visible = true
objdoc.application.printout
Msgbox "File printing"
Set objWord = Nothing
Set objdoc = nothing
End Sub
But the code doesn't work after I send the task or after
I close & save the task. It works fine when I first open
the form or "run this form" from the design page. How do
I get the code to work all the time?
Any help is appreciated
Bob
I'm building a custom task form (p.2 below)that has text
boxes and a command button. When I press the command
button I want the text from the text boxes (txt1, for
example)to go to certian spots on a word document
(test.doc with booksmarks). I got it to work using the
following code:
Sub CMDOpenWD_Click
Dim objWord 'As Word.Application
Dim objDoc 'As Word.Document
Dim objSelect 'As Word.Selection
Dim objDocItem 'As DocumentItem
dim control 'As outlook control
dim formpage 'As page
Set FormPage = Item.GetInspector.ModifiedFormPages("P.2")
Set control = formpage.controls("txt1")
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.open("C:\test.doc" )
Set objSelect = objWord.Selection
'msgbox objdoc.Bookmarks.count'sanity check one
objSelect.TypeText control.text
'Msgbox control.text'sanity check two
objword.visible = true
objdoc.application.printout
Msgbox "File printing"
Set objWord = Nothing
Set objdoc = nothing
End Sub
But the code doesn't work after I send the task or after
I close & save the task. It works fine when I first open
the form or "run this form" from the design page. How do
I get the code to work all the time?
Any help is appreciated
Bob