Page 1 of 1
[Solved] [VB.net] CopyCount error
Posted: Sat Nov 17, 2012 6:45 pm
by AquaTerra
Hello,
Sorry if I am posting this in wrong forum.
I am writing vb.net program that open .ott file, replace some text and then print it on selected printer. Problem is that "CopyCount" argument is not working (when I want to print multiple copies). When I debug my program i get this: "com.sun.star.lang.IllegalArgumentException:"
I would really appreciate if someone could help me with this. I know that I didn't tell you lot of details but this exception is all I got.
Thank you in advance!
Re: [VB.net] CopyCount error
Posted: Sat Nov 17, 2012 7:23 pm
by B Marcelly
Hi,
Nobody can help you without a look at your code.
Re: [VB.net] CopyCount error
Posted: Sun Nov 18, 2012 1:05 am
by AquaTerra
Code: Select all
--------------there are code before this part, but it is not important for this problem so I didn't include it for better readability
oSM = CreateObject("com.sun.star.ServiceManager")
oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
oDoC = oDesk.loadComponentFromURL("file:///C:\potvrda.ott", "_blank", 0, New unoidl.com.sun.star.beans.PropertyValue(0) {})
oRD = oDoC.createReplaceDescriptor
oRD.searchRegularExpression = True
oRD.setSearchString("<OPU>")
oRD.setReplaceString(OPU_broj.Text)
oDoC.replaceall(oRD)
Dim args As System.Array
Dim objDummy As Object = New Object
args = System.Array.CreateInstance(objDummy.GetType, 0)
objDummy = Nothing
Dim oArgs(1) As Object
Dim dArgs(2) As Object
If printerOmot.Length > 2 Then
oArgs(0) = MakePropertyValue(oSM, "Name", printerOmot)
Else
oArgs(0) = MakePropertyValue(oSM, "Name", printerDefault)
End If
oDoC.setPrinter(oArgs)
dArgs(0) = MakePropertyValue(oSM, "CopyCount", 2)
dArgs(1) = MakePropertyValue(oSM, "Wait", True)
oDoC.print(dArgs)
oDoC.Close(True)
if I don't include this line
Code: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", 2)
everything works OK, but if I include it then i get exception error as described in my first post
Re: [VB.net] CopyCount error
Posted: Sun Nov 18, 2012 3:33 am
by Charlie Young
AquaTerra wrote:
if I don't include this line
Code: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", 2)
everything works OK, but if I include it then i get exception error as described in my first post
Just a hunch. The 2 is defaulting to 32 bits, and CopyCount should be 16. Try
Code: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", CShort(2))
Re: [VB.net] CopyCount error
Posted: Sun Nov 18, 2012 10:02 am
by B Marcelly
Maybe no influence on your problem, but I see these errors :
Your URL address is incorrect. It should be :
file:///C:/potvrda.ott
This was a simple case... Much more complex if you have national characters or spaces in the path.
The declaration of your arrays should indicate the maximum value of the index, see documentation of VB.NET.
Code: Select all
Dim oArgs(0) As Object
Dim dArgs(1) As Object
And at which instruction does the exception occur ?
Re: [VB.net] CopyCount error
Posted: Sun Nov 18, 2012 11:47 am
by AquaTerra
Charlie Young wrote:
Just a hunch. The 2 is defaulting to 32 bits, and CopyCount should be 16. Try
Code: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", CShort(2))
Thank you, it seems that this fixed my problem. Will test it more later, but for now I don't receive error any more
B Marcelly wrote:Maybe no influence on your problem, but I see these errors :
Your URL address is incorrect. It should be :
file:///C:/potvrda.ott
This was a simple case... Much more complex if you have national characters or spaces in the path.
The declaration of your arrays should indicate the maximum value of the index, see documentation of VB.NET.
Code: Select all
Dim oArgs(0) As Object
Dim dArgs(1) As Object
And at which instruction does the exception occur ?
Thank you, fixed that
