Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

No printout from VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Smith - 28 Dec 2005 08:56 GMT
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
Jonathan West - 28 Dec 2005 11:58 GMT
Hi John,

Bit hard to say what the problem is on the information available. My first
suspicion is that you have neglected to transfer some of the code. Dows this
article help?

Distributing macros to other users
http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi all..
>
[quoted text clipped - 12 lines]
>
> Guy
John Smith - 28 Dec 2005 12:42 GMT
Hi Jonathan

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

On my computer its works..

> Hi John,
>
[quoted text clipped - 21 lines]
>>
>> Guy
Jonathan West - 28 Dec 2005 13:55 GMT
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?

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi Jonathan
>
[quoted text clipped - 29 lines]
>>>
>>> Guy
John Smith - 02 Jan 2006 06:27 GMT
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!!!

> Ok, you'll need to show me the relevant part of the code. Also, can you
> provide some more information, including the following
[quoted text clipped - 37 lines]
>>>>
>>>> Guy
Jonathan West - 02 Jan 2006 09:26 GMT
OK, some code now?

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi Jonathan!
>
[quoted text clipped - 46 lines]
>>>>>
>>>>> Guy
John Smith - 02 Jan 2006 10:56 GMT
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"

> OK, some code now?
>
[quoted text clipped - 48 lines]
>>>>>>
>>>>>> Guy
Jonathan West - 03 Jan 2006 09:23 GMT
> 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.

Signature

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 

John Smith - 05 Jan 2006 07:56 GMT
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

>> Hi again.
>> As I wrote - on my computer its working fine - so I believe the code is
[quoted text clipped - 9 lines]
> When targettiung multiple versions of Word, it is advisable to develop
> using the oldest version and then test on the newer ones.
Jonathan West - 05 Jan 2006 12:27 GMT
> Hi Jonathan
>
[quoted text clipped - 9 lines]
> 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...

Signature

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 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.