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

Using Word with VB

Status
Not open for further replies.

smash81

Programmer
Mar 12, 2001
88
KE
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
 
Thank you for your reply.However i was not able to solve the problem using this help.COuld you please elaborate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top