Printing Word Letters from an Access Project

  • Thread starter Thread starter Stephanie Neveu
  • Start date Start date
S

Stephanie Neveu

My user would like to do the following:
I was hoping that it could be done similar to the way outlook does it when
you have a contact highlighted and then go to "Actions" and you select "New
Letter to Contact"..it preprints the heading/address then give you the
opportunity to draft at that time the body of the letter.
Does anyone know any code that I can do this with a click of a button.
Thanks in advance...
Stephanie
 
Try something like the following:

Sub startWord()
Dim wordApp As Object
Dim theText As strign

Set wordApp = CreateObject("Word.application") 'startWord
theText = Forms![card_file]![yourtextbox]

With wordApp
.Documents.Add Template:="Normal", NewTemplate:=False,
DocumentType:=0
.Selection.TypeText Text:=theText
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText Text:="Dear "
.Application.Visible = True ' make Word visible
.Activate ' make Word the Active window
End With
Set wordApp = Nothing
End Sub

Hope this helps!

- Scott
 
Stephanie,

For better performance, you might want to add a reference to the Word object
into your database and then use :

Dim wordApp As word.application

Which has the same end result but is way faster.

Francois

ScottE said:
Try something like the following:

Sub startWord()
Dim wordApp As Object
Dim theText As strign

Set wordApp = CreateObject("Word.application") 'startWord
theText = Forms![card_file]![yourtextbox]

With wordApp
.Documents.Add Template:="Normal", NewTemplate:=False,
DocumentType:=0
.Selection.TypeText Text:=theText
.Selection.TypeParagraph
.Selection.TypeParagraph
.Selection.TypeText Text:="Dear "
.Application.Visible = True ' make Word visible
.Activate ' make Word the Active window
End With
Set wordApp = Nothing
End Sub

Hope this helps!

- Scott
-----Original Message-----
My user would like to do the following:
I was hoping that it could be done similar to the way outlook does it when
you have a contact highlighted and then go to "Actions" and you select "New
Letter to Contact"..it preprints the heading/address then give you the
opportunity to draft at that time the body of the letter.
Does anyone know any code that I can do this with a click of a button.
Thanks in advance...
Stephanie


.
 
Back
Top