I have a
vb code that when i click the Print button, it will print a
word file that is mailmerge, it works with no problem in most of computer in
my office, but one had problem, when I compile, it gave me an error message: Requsted object is not avalilable. The error happen on the code : .Destination= wdSendToPrinter
(Note: i select regular case).
>
The following is the code. I don't know what happen for that computer. It
works totally fine in other pc. Could someone please figure out this for me.
The following is the source code for the print button.
Private Sub cmdPrint_Click()
Dim wrd As Word.Application
Dim regletter As Word.Document
Dim reg2letter As Word.Document
Select Case Me![CertificationType]
Case "Apostille"
DoCmd.OpenReport "Apostille", acViewPreview, , "[GeneralID] =
Forms![GeneralInfo]![ID]"
Case "Regular"
DoCmd.SetWarnings False
DoCmd.OpenQuery "Qry_Regular_Report"
DoCmd.Close acQuery, "Qry_Regular_Report"
Set wrd = CreateObject("word.application")
wrd.Visible = True
wrd.WindowState = wdWindowStateMaximize
Set regletter =wrd.Documents.Openfilename:="c:\certification\reg ular.doc")
With wrd.ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.Execute
End With
wrd.ActiveDocument.Close (wdDoNotSaveChanges)
wrd.Quit
DoCmd.SetWarnings False
Case "Regular2"
DoCmd.SetWarnings False
DoCmd.OpenQuery "Qry_Regular2_Report", acViewNormal
Set wrd = CreateObject("word.application")
wrd.Visible = True
wrd.WindowState = wdWindowStateMaximize
Set reg2letter =
wrd.Documents.Open(filename:="c:\certification\reg ular2.doc")
With wrd.ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.Execute
End With
wrd.ActiveDocument.Close (wdDoNotSaveChanges)
wrd.Quit
DoCmd.SetWarnings False
Case Else
MsgBox "Select Certification Type for the record", vbOKOnly, "Select Type
of Certification"
End Select
End Sub