Printing Word Letters from an Access Project

  • Thread starter Stephanie Neveu
  • 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
 
S

ScottE

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
 
F

François Uldry

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top