How to print a Visio 2000 document from VBA !!?

L

Louis

Hello,

I try to print documents from VBA and ... that sounds easy, but turns out to
be quite complex.
Below a small subroutine intended for that purpose. However it does not
work.

The subroutine:
- starts visio
- load the document
- goes to the apropriate page
- and does not !!! alow me to print
The message is something like "property (print I suppose) not supported".
I tried a few options. See the code

Someone can help !!?

Louis
Note: I am using WindowsXP-professional, Access2003 (containing the examnple
code) and Visio2000 SP2
------------------------


Sub PrintVisioDoc(TheDoc As String, ThePage As Integer, ThePrinter As
String)

Dim visioApp As New Visio.Application
Dim comAddIn As Office.comAddIn
Dim AppPrinter As String

Dim docsObj As Visio.Documents
Dim docObj As Visio.Document
Dim pagsObj As Visio.Pages
Dim pagObj As Visio.Page

'Create instance of Visio
Set visioApp = New Visio.Application
visioApp.Visible = True
'AppPrinter = xlsApp.ActivePrinter
'xlsApp.ActivePrinter = ThePrinter


visioApp.Documents.Open (TheDoc) 'en een paar patches later ... dit
werkt
Set docObj = visioApp.ActiveDocument

Set pagsObj = docObj.Pages
Set pagObj = pagsObj.Item(ThePage) 'pagObj now contains page() name

pagObj.Print 'property not supported ???
'visioApp.ActiveDocument.Pages(ThePage).Print 'property not supported
???
'visioApp.ActiveDocument.PrintOut 'property not supported ???
'pagsObj.Item(1).Print 'property not supported ???


'xlsApp.ActivePrinter = AppPrinter
visioApp.Quit
Set visioApp = Nothing

End Sub
 
J

JuneTheSecond

You could succeed in printing, if you use dummy object.
Please add it, for example;
Dim pagObjTemp As Object
Dim strDummy As String
Set pagObjTemp = pagObj
strDummy = pagObjTemp.Print
You could read about it in the notes on help about Print method.
Hope this could help.
 
L

Louis

Hello "June",

GREAT!! It worked! I never ever could have invented this code, but it
works. How buggy can MS-software be!

Note that the reason the printer selection is still only comment, is that I
have a comparable function for prining excell, but that Excell
is crashing my XP when executing that little peace of IMHO correct VBA-code.

But as I wrote before, thing as printing a file should be fairly easy and
standard, should be .......

Thanks again,


Louis
 

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