OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to print a doc via VB6 with specific printing settings

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
joel
Newbie
Newbie


Joined: 22 Jan 2004
Posts: 1

PostPosted: Fri Jan 23, 2004 12:08 am    Post subject: How to print a doc via VB6 with specific printing settings Reply with quote

Hello Everybody.
I 've been trying to print a (Oo)document via VB6 using the awful code you can
see below. But it deosn't work. Help me pleeeeeease....


Using the Dispatcher method, you can print the whole document without any problem.
But i can't find a way to specify printing settings programatically through VB6.
What i would like to do is tell the printer to print, for exemple, only the page 1
of the document.(or pages 1 to 3)

My Code :

Dim opt(0)
Set OoFrame = objDesktop.getCurrentFrame()
Set OoDispatcher = objServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
Set opt(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
opt(0).Name = "Text"
opt(0).Value = "1-3"
OoDispatcher.executeDispatch OoFrame, ".uno:Print", "", 0, opt()


i'm waiting for your feedback.
JOEL
Back to top
View user's profile Send private message
heffalump
General User
General User


Joined: 15 Jan 2004
Posts: 21
Location: Germany, Pliezhausen

PostPosted: Fri Jan 23, 2004 1:14 am    Post subject: Reply with quote

Hi Joel,
here is my VB code for printing (some kind of raw - but it works, I will optimize it later)
Code:

'...
Set objDocument = objDesktop.loadComponentFromURL(url, "_blank", 0, args)
...
'Now printing out

Dim args(2) as object
Set args(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args(0).name = "Copies"
args(0).Value = 1
Set args(1) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args(1).name = "Collate"
args(1).Value = False
Set args(2) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args(2).Name = "RangeText"
args(2).Value = "2-3"

'Print() wird sonst als VB-eigene Methode verstanden!
CallByName objDocument, "print", VbMethod, args()

If you use the print() method of the document model you have to use the VB-function CallByName otherwise VB tries to apply its own bulit-in function print on the objDocument object. This example prints pages 2 to 3.
Regards,
Werner
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Fri Jan 23, 2004 5:02 am    Post subject: Reply with quote

Thank you so much, Werner.
You simply saved my life.
Now It works wonderfully

Best regards

JOEL
Back to top
Guest






PostPosted: Fri Jan 23, 2004 7:56 am    Post subject: Reply with quote

Hello Werner

Your code helped me a lot.
Now I've just one more question.

The problem is right there:
Dim args(2) as object
Set args(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args(0).name = "Copies"
args(0).value=5

I would like to be able to print several documents (4 or 5) in one go.
But there is something wrong with the piece of code abode.
I guess something is missing.
I tried "CopyCount" instead of "Copies" but it doesn't seem to change anything

Let me know, if you have an idea.
Thank you

JOEL
Back to top
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 4021
Location: Lawrence, Kansas, USA

PostPosted: Fri Jan 23, 2004 8:39 am    Post subject: Reply with quote

You are dimensioning the args as...

Dim args(2) as object

but then you only fill in args(0) with a PropertyValue.



The possible PrintOptions are documented here....
http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrintOptions.html
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
heffalump
General User
General User


Joined: 15 Jan 2004
Posts: 21
Location: Germany, Pliezhausen

PostPosted: Mon Jan 26, 2004 12:12 am    Post subject: Reply with quote

If you need only one single property to set then you have to dimension the args() array as args(0)
Quote:
Dim args(0) as object
Set args(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args(0).name = "Copies"
args(0).value=5

If you need more properties then you have to fit the array dimension to the number of properties you will set. Each array element is an object (instanciated by the Bridge_GetStruct() method) with the properties "name" and "value".
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group