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!
[Solved] [VB.net] CopyCount error
[Solved] [VB.net] CopyCount error
OpenOffice 3.3 on Windows 7
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: [VB.net] CopyCount error
Hi,
Nobody can help you without a look at your code.
Nobody can help you without a look at your code.
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: [VB.net] CopyCount error
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)
Code: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", 2)
OpenOffice 3.3 on Windows 7
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: [VB.net] CopyCount error
Just a hunch. The 2 is defaulting to 32 bits, and CopyCount should be 16. TryAquaTerra wrote: if I don't include this lineeverything works OK, but if I include it then i get exception error as described in my first postCode: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", 2)
Code: Select all
dArgs(0) = MakePropertyValue(oSM, "CopyCount", CShort(2))
Apache OpenOffice 4.1.1
Windows XP
Windows XP
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: [VB.net] CopyCount error
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.
And at which instruction does the exception occur ?
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
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: [VB.net] CopyCount error
Thank you, it seems that this fixed my problem. Will test it more later, but for now I don't receive error any moreCharlie 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, fixed thatB 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.And at which instruction does the exception occur ?Code: Select all
Dim oArgs(0) As Object Dim dArgs(1) As Object
OpenOffice 3.3 on Windows 7