Hello,
I am using word to print some of my reports.Could anyone tell me how i can disble the system message that is displayed before a document gets printed.The message just informs the user that the document is printing and whether or not to cancel the print job.I want my application to start printing as soon as the user clicks the button.No message is to be displayed.
The code i have used is:
Option Explicit
Dim objword As Word.Application
Private Sub cmdprint_Click()
Dim temp As String
Set objword = New Word.Application
' Disable command button to prevent object being recreated
cmdprint.Enabled = False
' Name of report file, change path to whatever is applicable
objword.Documents.Open ("c:\sailesh\trialreport.doc"
' Calling subroutines with header and data
Call RepPara("naam", txtname)
' Saves report with a new filename
'objword.ActiveDocument.SaveAs ("c:\sailesh\NewReport.doc"
objword.ActiveDocument.PrintOut
' Quit Word
objword.Quit
' Inform user that report is created
MsgBox "Report Created"
txtname = ""
cmdprint.Enabled = True
' Clear our pointer to word
Set objword = Nothing
End Sub
Private Sub RepPara(Header As String, Data As String)
With objword.Selection.Find
.ClearFormatting
.Text = Header
.Execute Forward:=True
End With
Clipboard.Clear
Clipboard.SetText (Data)
objword.Selection.Paste
Clipboard.Clear
End Sub
Cheers
I am using word to print some of my reports.Could anyone tell me how i can disble the system message that is displayed before a document gets printed.The message just informs the user that the document is printing and whether or not to cancel the print job.I want my application to start printing as soon as the user clicks the button.No message is to be displayed.
The code i have used is:
Option Explicit
Dim objword As Word.Application
Private Sub cmdprint_Click()
Dim temp As String
Set objword = New Word.Application
' Disable command button to prevent object being recreated
cmdprint.Enabled = False
' Name of report file, change path to whatever is applicable
objword.Documents.Open ("c:\sailesh\trialreport.doc"
' Calling subroutines with header and data
Call RepPara("naam", txtname)
' Saves report with a new filename
'objword.ActiveDocument.SaveAs ("c:\sailesh\NewReport.doc"
objword.ActiveDocument.PrintOut
' Quit Word
objword.Quit
' Inform user that report is created
MsgBox "Report Created"
txtname = ""
cmdprint.Enabled = True
' Clear our pointer to word
Set objword = Nothing
End Sub
Private Sub RepPara(Header As String, Data As String)
With objword.Selection.Find
.ClearFormatting
.Text = Header
.Execute Forward:=True
End With
Clipboard.Clear
Clipboard.SetText (Data)
objword.Selection.Paste
Clipboard.Clear
End Sub
Cheers