VB 2nd call of VPE in the same form results in an error

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

VB 2nd call of VPE in the same form results in an error

Postby ralph1 » Tue May 25, 2010 4:22 pm

Hello,

I have a vb5/vb6 program where i have put the control on my form.

The program has a listview where i show some database-entries with purchase-headers. Now i want to print / preview from one invoice the purchase-lines.

The first time everything is ok. But after i close the vpe-preview i want to print /preview a second invoice i get the error, that the vpe-control isn´t loaded.

By pressing the print-button i call the following sub where it stops near vpe1.AutoBreakMode :

Private Sub Druck_Starten()
VPE1.Caption = "Lieferschein/Rechnung/Gutschrift Drucken = F2 Schließen= ALT+F4"
VPE1.OpenDoc
VPE1.SwapFileName = (Environ("temp") & "\vpe" & Format(date) & Format(Time) & ".vpe")
VPE1.AutoBreakMode = AUTO_BREAK_ON ' ist default eingestellt
VPE1.UnitTransformation = VUNIT_FACTOR_CM 'ist default eingestellt
VPE1.PageWidth = 21
VPE1.PageHeight = 29.5
VPE1.PageOrientation = 1 ' 1= hoch , 2 = quer
VPE1.nTopMargin = 2.5

End Sub


I don´t know where is the problem. The only way is to close my form and restart it.

Has anybody hints?

Thanks a lot.

Ralph
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Tue May 25, 2010 4:59 pm

You must set SwapFileName before calling OpenDoc. SwapFileName may not be set after a document has been opened. Therefore your code should always throw an error. What version / edition of VPE are you using? What is the error message?
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm

Postby ralph1 » Wed May 26, 2010 8:47 am

VPE 6.0 and vb5sp3

when i put the SwapFileName before calling OpenDoc i never get a print / preview. I get the error message which i got until now with my 2nd try to print/preview.

Here the error message:

Laufzeitfehler '-2147220480(80040400)'
VPEAX01: The VPE document is not open.You need to call OpenDoc prior to this operation.
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby ralph1 » Wed May 26, 2010 12:57 pm

as a hint: without using the swapfile all works fine.
Last edited by ralph1 on Thu May 27, 2010 3:18 pm, edited 1 time in total.
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Wed May 26, 2010 5:14 pm

The error message indicates that the document must be open before a specific operation may be executed.

I need to know what version and edition of VPE you are using.
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm

Postby ralph1 » Thu May 27, 2010 3:29 pm

at the moment i play/try VP6.0 community
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Thu May 27, 2010 3:50 pm

Please see in the manuals (help files) the description of

Code: Select all
property string VPE.Caption

    read / write; design & runtime, closed document required


Obviously the document has not been closed, when you execute the code a second time.
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm

Postby ralph1 » Mon Jun 07, 2010 2:14 pm

thanks for the hint but i thought i close the vpe-preview with the x - button in the right corner. Could this be a memory problem or an unloaded function by using the swap-file?
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Tue Jun 08, 2010 12:07 pm

First of all, if you do not get a preview when you set SwapFileName before calling OpenDoc, then check your code and your environment. Maybe you have no access permissions to the directory where you want to create the swap file.

SwapFileName must be set, before calling OpenDoc, otherwise it has no effect. Please read the manuals.

Second, if the preview is closed, the document is also closed. Except you set the property AutoDelete = false. In this case the document is not closed. The property AutoDelete is not supported by the Community Edition, therefore it is always true.

I wrote extra some code to test SwapFileName and the close-document behaviour, both is working as it should.
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm

Postby ralph1 » Wed Jun 09, 2010 8:53 am

i am confused - because (as i wrote before)

when i put the SwapFileName before calling OpenDoc i still get the error message

Laufzeitfehler '-2147220480(80040400)'
VPEAX01: The VPE document is not open.You need to call OpenDoc prior to this operation.

Only when i put SwapFileName after opendoc it works one time and i get these message by the next call to print.

So in your enviroment it works as it should - in my enviroment it does not. I think it should be a problem on my machine/ VB.

Thanks for your time to test und try to help me.
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Wed Jun 09, 2010 1:34 pm

Set a break point at the beginning of your method "Druck_Starten()" and step through the code. The exception is thrown when you set the property Caption. This clearly indicates that the document is NOT closed as you execute your code a second time. It may be related to setting the SwapFileName because the path / file name is illegal or you have no access permission to the path / file. This will cause OpenDoc() to fail, which might leave you an open document.

Solution: check the property LastError after calling OpenDoc() and handle any possible errors.

The following is an excerpt from the help file:
property string VPE.SwapFileName
read / write; design & runtime, closed document required
.
.
.
You can check for error conditions - for example, if there is not enough free space left on disk for the SwapFile - by testing the property LastError after calling OpenDoc and each time after calling PageBreak.


Please read the docs.
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm

Postby ralph1 » Wed Jun 09, 2010 4:19 pm

I found the error:

Private Sub Druck_Starten()
MsgBox (VPE1.SwapFileName)
vpe1.swapfilename=""
VPE1.Caption = "Lieferschein/Rechnung/Gutschrift Drucken = F2 Schließen= ALT+F4"
VPE1.OpenDoc
VPE1.SwapFileName = (Environ("temp") & "\vpe" & Format(date) & Format(Time) & ".vpe")
End Sub
-------------------------------------
in first call the msgbox is empty -
by the next call it has the value which i have set by the first call

and here is the mistake. I have to clear vpe1.swapfilename and then it runs.

But i have never found a file like my swapfilename - which means (as you wrote) it has no effect.

------------------------------------
And now here is the answer:

the problem ist the filename. After i wrote this reply i tried a simple filename like c:\vpe.vpe - and it works. And i have found a file like c:\vpe.vpe.

But after the preview is destroyed the file further exists. And a second print produces a mixed output.

So i have first to kill an exisiting file.

Ralph
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Thu Jun 10, 2010 7:10 am

It is intended that the Swap File is persistent. This allows for example to assemble documents. This is documented.

But the persistent swap file is definitely not the cause for the problem you described. The path or file name were wrong or you had no access permissions to the path / file.
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm

Postby ralph1 » Thu Jun 10, 2010 8:16 am

I´m sorry - i´m so stupid.

The problem isn´t vpe - the problem was my format (time) - string. It results as xx:xx:xx - double dots are not allowed as filenames. Now i use format (time,"hh_mm_ss") and everything works fine.

I have forgotten what "format (time)" produces.


Thanks for the trouble!

Ralph
ralph1
 
Posts: 8
Joined: Tue May 25, 2010 4:18 pm

Postby IDEAL Software Support » Thu Jun 10, 2010 2:35 pm

I am glad to hear that this issue is solved. Please take into account our time for supporting this issue. It would be nice if you would honour this by upgrading to a commercial version.
IDEAL Software Support
 
Posts: 1622
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 65 guests