Jonathan west - Word 2000 still does not print

J

Joe Cartoon

Hi Jonathan,

I just installed WINXP+VB6 SP6 + OFFICE 2000.

Word does not print :(
As I wrote before -
1. The document is created and exists on the HD.
2. I see the printer icon

Here is the code:
Thanks in advance.

Guy

''''''''''''''
On Error GoTo EH

Dim B As Boolean
Dim S As String

'wdAlignParagraphLeft = 0
'wdAlignParagraphCenter = 1
'wdAlignParagraphRight = 2
'wdUnderlineNone = 0
'wdUnderlineSingle = 1

Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim wRange As Word.Range
Dim wField As Word.Field
Dim wParagraph As Word.Paragraph

B = True

DoEvents

If Not (WordDoc Is Nothing) Then
WordDoc.Close
Set WordDoc = Nothing
End If
If Not (WordApp Is Nothing) Then
WordApp.Quit
Set WordApp = Nothing
End If

Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Add

S = "bla bla bla"
Set wParagraph = WordDoc.Content.Paragraphs.Add()

With wParagraph
.Range.Text = S
.Format.SpaceAfter = 5
.Range.InsertParagraphAfter
End With

Call WordDoc.SaveAs("C:\123.doc")
Call WordDoc.PrintOut(True)

DoEvents

If Not (WordDoc Is Nothing) Then
Call WordDoc.Close(False)
End If
If Not (WordApp Is Nothing) Then
Call WordApp.Quit(False)
End If

EOF:

If Not (WordDoc Is Nothing) Then
Set WordDoc = Nothing
End If
If Not (WordApp Is Nothing) Then
Set WordApp = Nothing
End If

bmfPrintMakeCardReportDOC = B

Exit Function

EH:
B = False
Call gsReportSystemError("Sub name", Err.Number, Err.Description)
Resume EOF

''''''''''''''
 
J

Jonathan West

Hi Joe,

Looks to me as if you are using background printing, which allows VBA to go
on to the next line of code while the printing proceeds. But you are almost
immediately closing Word after that, before Word has a chance to finish
spooling the print job. Take a look at this article for a cure.

How to find out whether Word has finished printing
http://www.word.mvps.org/FAQs/MacrosVBA/WaitForPrint.htm

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top