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

Add text in Word from Access 1

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
0
0
US
Hello all

I have a word document opened from access and i would like to add some text as soon as the Word document is opened so when i print the doc. it will print in the header the instruction ID.
Here is the code. (Thank you very much for any help"

Private Sub cmdowd_Click() 'Open Word Document
Dim objWord As Object
Dim ffile As String
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
ffile = Application.CurrentProject.Path & "\" & Me.InstructionID & ".doc"
If Dir(ffile) <> "" Then
objWord.Documents.Open ffile
Else
objWord.Documents.Add
objWord.ActiveDocument.SaveAs ffile
' objWord.ActiveDocument.TypeText Text:="ID=7262362"
End If
Set objWord = Nothing


The instruction objWord.ActiveDocument.TypeText Text:="ID=7262362" does not work


 
Replace this:
objWord.ActiveDocument.TypeText
with this:
objWord.Selection.TypeText

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
now can you or anybody help sayin how can i print that word document in access.

Thanks
 
objWord.ActiveDocument.PrintOut False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top