|
-
Oct 16th, 2000, 05:55 AM
#1
Thread Starter
Lively Member
I have a word document I would like to print when pressing a command button on my app.
How does one do this I ask with tears in my eyes.
Thanks.
dan.
-
Oct 16th, 2000, 10:39 AM
#2
Lively Member
Printing Word Document
Hi Dan,
Here is the solution for your problem.Follow the steps:
1. In the VB click the Project>References>Microsoft Word Object8.0(don't worry about the version.Take the version you have).
2. After giving reference to word object,write the following code in the button's click event.
'Declare in the general declaration section
Dim wWord As Word.Application
Private Sub Command1_Click()
Set wWord = New Word.Application
'Use this code if you want to open any document.In this i saved "hi.doc" on my desktop
Documents.Open "c:\windows\desktop\hi.doc"
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
'This code prints the current page of the active document.
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
'This code prints the first five pages of the document in the active window.
ActiveWindow.PrintOut Range:=wdPrintFromTo, From:="1", To:="5"
'This will print all the documents in current folder.
adoc = Dir("*.DOC")
While adoc <> ""
Application.PrintOut FileName:=adoc
adoc = Dir()
Wend
End Sub
Hope this will help you...
Good Luck
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|