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

need command button to print linked WORD document

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I hope this is the correct forum for this question....
I need to make a command button on a form that will print a WORD document stored as a link in an OLE field. I have linked the documents to save space in the ACCESS table.
Any help on how to work with WORD automation, epsecially linked fields would be most appreciated.

Thank you
Doug_R
 
I do this in a couple of instances with my inhouse databases--what I have done is create a query to pull the information that I need for letters and mail merge---

call procedure from cmdbuttonPublic Sub PrintLetter()

On Error GoTo Err_Startword
Dim Wrd As Word.Application, IsRunning As Boolean
Dim MyMerge As Word.MailMerge

IsRunning = True
Set Wrd = GetObject(, Word.Application)
'Wrd.Visible = True
Wrd.Documents.Open filename:="G:\UNITS\DELQ\LetterPrint.doc"
Set MyMerge = Wrd.ActiveDocument.MailMerge
If MyMerge.State = wdMainAndDataSource Then
With MyMerge
.DataSource.FirstRecord = 1
.DataSource.LastRecord = 250
.Destination = wdSendToPrinter
.Execute
End With
Do While Wrd.BackgroundPrintingStatus <> 0
DoEvents
Loop
End If
Wrd.ActiveDocument.Close SaveChanges:=False



If IsRunning = False Then 'Word is not running
Wrd.Quit
End If
Exit Sub

Hope this helps

I found it in Access 97 Power Programming by F. Scott Barker --when changed over to Access 2000 converted fine--Chapter 10-11

 
Thank you for the reply
I am not trying to do a mail merge. I have stored some Word documents as links in an OLE type field in a table.
I need to be able to show the document an also be able to print the document using a button on the ACCESS form. I have used an OLE control on the form and I can display the WORD document. Now how do I print that document using a command button on the form?

Thanks
Doug_R
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top