No printout from VB

J

John Smith

Hi all..

I use VB6 + VBA + OfficeXP.

My program produces reports using word templates.
As always <grin> from my computer all is working fine.
On another computer - the document wont print.
I can see the printer icon + I saw in the printers list that the documents
column displayed "1" as for the document I sent to the printer.
I tried to manually print using other programs (both notepad and word) - It
worked.

I am clue-less
Please help

Guy
 
J

John Smith

Hi Jonathan

Its not the case here...
Its pure VB code without macros.

On my computer its works..
 
J

Jonathan West

Ok, you'll need to show me the relevant part of the code. Also, can you
provide some more information, including the following

1. Which version of Office is on the other computer?
2. Are you using early binding or late binding?
3. When the print failure occurs, are there any error messages?
4. On the other computer, is the printer currently set to "Work offline?
 
J

John Smith

Hi Jonathan!

1. Both computers = Windows XP + Office XP.
2. Of course I use objects and not word objects... :)
3. No errors - the printer icon appears on the system tray.
4. No ... I checked that :)

Thanks for the efforts!!!
 
J

John Smith

Hi again.
As I wrote - on my computer its working fine - so I believe the code is ok.

I wrote a simple sample ... but it worked on both computers :(
p.s. the office on the second computer is 2k not xp...

thanks again!



Thats the code more or less:


Dim WordApp As Object
Dim WordDoc As Object
Dim wRange As Object
Dim wField As Object
Dim wParagraph As Object
Dim wTable As Object
Dim wCell As Object


Set WordApp = CreateObject("Word.Application")
Call WordApp.Documents.Add
Set WordDoc = WordApp.ActiveDocument

Call WordDoc.Paragraphs.Add
Set wParagraph = WordDoc.Paragraphs(WordDoc.Paragraphs.Count)

With wParagraph.Range
.Font.Name = "Arial"
.Font.SizeBi = 12
.Font.BoldBi = True
.Font.Size = 12
.Font.Bold = True
.Font.Underline = 0
.Text = "BlaBla"
.ParagraphFormat.Alignment = 1
End With

wParagraph.SpaceAfter = 5

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

MsgBox "done"
 
J

Jonathan West

John Smith said:
Hi again.
As I wrote - on my computer its working fine - so I believe the code is
ok.

I wrote a simple sample ... but it worked on both computers :(
p.s. the office on the second computer is 2k not xp...

THAT is probably the problem. Your simple sample isn't making use of any new
features of XP, but your full program probably is, and Word 2k chokes on the
code because it doesn't know what to do with it.

When targettiung multiple versions of Word, it is advisable to develop using
the oldest version and then test on the newer ones.

--
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
 
J

John Smith

Hi Jonathan

I agree with you - might be that word 2k chokes - especially because tables
are involved.

HOWEVER :)
In my case - I see the printer icon on the system tray

Important note: Before calling print ,the program saves the file on the disk
(calling saveas) - and I can see the file there - with no problems.

I took msword9.olb to my computer and tried to use dim x as word.document -
just to see if it will print from my pc - and it did.

It is still a riddle for me ...

Thanks again for all the efforts
 
J

Jonathan West

John Smith said:
Hi Jonathan

I agree with you - might be that word 2k chokes - especially because
tables are involved.

HOWEVER :)
In my case - I see the printer icon on the system tray

Important note: Before calling print ,the program saves the file on the
disk (calling saveas) - and I can see the file there - with no problems.

I took msword9.olb to my computer and tried to use dim x as
word.document - just to see if it will print from my pc - and it did.

That will have no effect. msword9.olb is useless without the rest of Word.
If your code still worked it is because it was not using msword9.olb.
It is still a riddle for me ...

Thanks again for all the efforts

You're going to have to get a copy of Word 2000 onto a development machine
and test it there. If you don't want to dedicate a whole separate machine to
this, then you might get a copy of VirtualPC and use it to install Word on a
virtual machine. Don't attempt to install multiple versions of Office on the
same PC except in separate boot partitions or virtual machines. While it is
possible to get it working it is scarcely a realistic environment for
testing how things will go for customers.

The likely cause is that you are using an object or parameter in your code
that is available in the Word XP object model but was not present in the
Word 2K object model, and Word 2K is choking on a command it doesn't know
how to deal with. but without seeing the actual code, I have no way of
knowing which is the offending item.

You can't really expect to repro the problem unless you also repro the
conditions under which the problem occurs. Unless & until you do that, it
will remain a riddle...


--
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