ActiveX with Access
Printed From: www.exp-systems.com
Category: PDF reDirect
Forum Name: Programming
Forum Discription: VBA and Batch Tools to control PDF reDirect Pro
URL: http://www.exp-systems.com/Forum_exp/forum_posts.asp?TID=427
Printed Date: 22 Nov 24 at 9:23AM
Topic: ActiveX with Access
Posted By: RickNTA
Subject: ActiveX with Access
Date Posted: 02 Jul 08 at 8:38PM
Hi Michel -
I'm working with the Access sample code (nicely commented, BTW!) to integrate with an existing app of ours, and running into some problems. I'm using the Convert2PDF function in the sample, and trying to allow the user to change the filename of the PDF (I need to set a filename but let the user override it, especially if the file already exists).
I assume that Settings_Overwrite should do what I want for an existing file, but it appears that:
1. On PC #1, OW_WARN pops up a dialog but the user input is ignored and the file gets overwritten. On PC #2, it seems to have no effect - file gets overwritten.
2. OW_SAVEAS_DIALOG actually causes it to create a new sequence number
3. On PC #1 (with Acrobat installed), OW_NEW_SEQ_NUMBER causes Acrobat to throw an error; on PC #2 (only Adobe Reader installed) file gets overwritten.
I'm confused! Am I missing something basic, or approaching this wrong? Is there any more detailed doc on the DLL settings?
In another post you said "So, I am wondering if perhaps you are using an old version of my
sample VBA code. The latest programming sample code is v2.2.5." The header on the sample code I got about 3 weeks ago lists Version as 2.2.0 Revision 0, dated 8/19/2006 - did I somehow get an old version?
thx - Rick N.
|
Replies:
Posted By: Michel_K17
Date Posted: 02 Jul 08 at 10:06PM
Hi Rick,
Yes, the Overwrite function should run as intended, so I'll go re-confirm that it is working properly (or not) for me, or if there is a problem. It should work (famous last words) as it is the same code that I use in PDF reDirect Pro, but I'll make sure.
For the header text - that makes reference to the version of the sample code in Access - which changes very rarely. You would need to check instead the version provided of the ActiveX component: ActiveX_PDF_Pro.dll (ie Right-click on the DLL >> Properties >> Version tab)
It should say: v2.2.5
About Item #3 (w Acrobat installed): Are you using the Acrobat engine, or are you still relying on the default GS engine?
Anyway, give me a few minutes, and I'll give you an update of what I find out.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: Michel_K17
Date Posted: 03 Jul 08 at 12:36AM
Hi Rick,
Yes, you are right: I found a couple of problems.
The first is in the Access sample code. Go to the beginning of the "Convert2PDF" function in the module and delete (or comment out) the line of code that deletes the existing PDF file (it should let the Batch printer do that based on the settings entered). By deleting the file, it prevents the warning from appearing.
The lines that need to be deleted are:
' ' Delete any old file by the same name ' If Dir$(MyOutputPath & "\" & MyOutputFilename) Then Kill (MyOutputPath & "\" & MyOutputFilename)
There is another problem with the program that does the conversion which I fixed this evening. The executable is called "Capture.exe". Simply delete it, and replace it with the one inside the zip file located [ http://www.exp-systems.com/PDFreDirect/Download/Capture_v225a_w_Access_Fix.zip - here ]. This error caused the overwrite setting to act erratically.
This will get you going for now. Obviously, I will need to re-compile the entire package with the fix, but at least this will allow you to continue with your testing.
Thanks for pointing out these problems to me.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 03 Jul 08 at 12:45AM
Hi Michel -
The DLL version is 2.2.0.5, but I assume that discrepancy is the usual Windows problem with adding an extra decimal - or do I really have an old version?? I was concerned about the version of the sample code because your earlier post had said that should be 2.2.5 also.
I'm using the GS engine (according to Preferences in the UI).
thx - Rick
|
Posted By: RickNTA
Date Posted: 03 Jul 08 at 12:54AM
You're up late!
The lines that need to be deleted are:
' ' Delete any old file by the same name ' If Dir$(MyOutputPath & "\" & MyOutputFilename) Then Kill (MyOutputPath & "\" & MyOutputFilename)
Good point! I had already fixed the Type Mismatch error there earlier but forgot it's deleting existing files - that would definitely obscure the results. There is another problem with the program that does the conversion which I fixed this evening. The executable is called "Capture.exe". Simply delete it, and replace it with the one inside the zip file located [ http://www.exp-systems.com/PDFreDirect/Download/Capture_v225a_w_Access_Fix.zip - here ]. This error caused the overwrite setting to act erratically.
Thanks - I'll try it very soon...
thx - Rick
|
Posted By: RickNTA
Date Posted: 03 Jul 08 at 5:39PM
Hi Michel -
Took longer than planned, but I've now tested. Definitely helps to comment out the line that deletes the existing file when I'm testing file overwite settings! (duh!!) And yes, the new Capture.exe seems to have fixed the problem with the constant values / meanings, so thanks again for the quick action on that.
I also realize now that I was getting weird results partly because of the lines further down that work with and open the file named MyOutputFilename, which isn't the right file if the user just changed the filename (using the OW_SAVEAS_DIALOG constant) or the app just changed the filename (using OW_NEW_SEQ_NUMBER).
Now I see more clearly: the most important item is letting the user specify the filename, so I need to get the filename returned by the save as dialog, and then use that in the lines below It doesn't look like the PDF object has a property for that. Any suggestions?
thx - Rick N.
|
Posted By: RickNTA
Date Posted: 03 Jul 08 at 5:43PM
I should clarify on that last point: I'm pretty sure the Win API gives access to the saved file name, but since the PDF object is calling the save as dialog, I don't think any return values will be available in the calling VBA code - so I think you'd have to add a property to the object.
|
Posted By: Michel_K17
Date Posted: 04 Jul 08 at 9:33AM
Hi Rick,
You are right on the money with your last post.
The batch printer settings has a setting that allows you to ask it
to open the PDF after it has been created (go into the main program,
choose "Preferences" then "Batch Printers" and it's in the list).
Yet, in my sample code, that is not shown, and instead, I rely on
my own code to do that, and, as you said, it does not work if the user
changes the path and/or filename via the "Save as..." dialog.
The "open" batch printer is a (fairly) recent addition to the main
program which I have not yet incorporated in the ActiveX control, but
it will be easy for me to do, so I'll work on that and include it in
the next version (v2.2.6) which I will release by Monday.
By the way: v2.2.5 is the same as v2.2.0.5. I use a three digit
versioning system, but Windows supports 4 digits, and my 3rd digit gets
re-mapped to the 4th during compilation. I can see how that might be
confusing, but yes, they are the same.
So, to summarize: you can expect v2.2.6 on Monday with:
-
the new Batch Setting for opening the PDF,
- fixing the VBA sample code in Access (deleting that line),
- adding support for ANSI pages, and
- fixing a bug
in the code to upload PDF files to a FTP address.
Sounds like we are almost there.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 04 Jul 08 at 4:48PM
Hi Michel -
Thanks - I hadn't noticed that section on Batch Printer settings - between that and one of your old posts about the INI file I'm getting a much clearer picture of what's going on (and the more I see, the more I like PDF reDirect!).
Something you should know: I've been trying to use that "View in PDF Reader" setting in the Batch Printer section and find that if I set it to Yes there, it gets set back to No after running the code, even though I don't see a setting for it in the code. Strange... but may be related to this:
The new Capture.exe seems to have stopped fixing the overwrite setting / constant values problem! Very weird - it was clearly working (I thought!) on two PCs yesterday and now seems to have reverted back, at least on PC#2 - OW_SAVEAS_DIALOG behaves like OW_NEW_SEQ_NUMBER, etc. Capture.exe in PDR reDirect folder is 312 kb dated 7/2/08 11:19PM so I think I still have the right one - I have the old one renamed in the same folder to make it clear. Am I losing my mind?? (again!?) :-) I've had the PDF reDirect UI open while I test; will that cause a problem?
Version numbers: yes, I'm familiar with the issue - especially VB using 3 digits but Windows using 4 - and then there's InstallShield that adds 0's - fun and games! I had to track versions in a spreadsheet for one of VB projects just to keep the numbers straight...
Looking forward to the new version on Mon.! Hope it doesn't take a lot of your weekend. Happy 4th!
thx - Rick
|
Posted By: Michel_K17
Date Posted: 04 Jul 08 at 6:19PM
Hi Rick,
Thanks for the vote of confidence.
No worries about my time: this is a labor of love, and I'm about to stop to meet with friends and watch the fireworks. :)
Weird about Capture.exe stopping to work. If you can wait to Monday, I'll have a proper download for you.
This latest exercise is further convincing me to convert Capture.exe as an ActiveX component (eventually) rather than it's current status as an executable. The biggest benefit to you is that you would get access to all of the functions I have in there, and I can introduce "events" that could be used to trigger your VBA code (for example, to annouce a completed job).
Anyway, what I thought was going to be a 30 minute job has turned into a 5 hour exercise so far. The biggest problem is that the printer does it's thing and if there is anything that causes the filename to change, then that information is not available to your VBA code. (ie can't do any post-processing like adding stamps, opening the PDF).
I am continuing to explore my options. I'll keep you posted.
Happy 4th!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: Michel_K17
Date Posted: 05 Jul 08 at 10:59AM
Hi Rick,
Quick update. Things are going well: it looks like I'll have something working for you as planned.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 05 Jul 08 at 4:26PM
Hi Mike -
Thanks for the update - hope it's a productive Saturday for you! I'm taking the time off to clean out the office, etc. - great fun...
Re. Capture.exe - I tried again later, after closing the UI, and it was back to working fine - and when I reopened the UI and ran the code it continued to work properly - so I'm baffled... but let's chalk that one up to gremlins or solar flares and I'll let you know if I see that behavior again.
I think converting Capture.exe to an ActiveX component is a great idea - the more functionality exposed, the better. We have some further plans for this app (the one our client is getting the 100-user license for) - want to get into merging docs and managing docs better - so we may be able to use more functionality soon (next few months). And we do have other clients and systems, at least one of which could use some PDF magic.
Yes, it would be good if our VBA could get the changed filename from the batch printer object - I think we get more flexibility that way. If not, though, we just need to get the "View in PDF Reader" setting in the Batch Printer section to stick when we run the code, or get the ability to set that from code.
thx - Rick
|
Posted By: Michel_K17
Date Posted: 06 Jul 08 at 9:38AM
Hi Rick,
What I am doing is providing code to allow you to display the Save As... box yourself. This gives you access to the filename that the user selected. Then, you can set the Batch printer to "Overwrite_No_Warning".
I have also finalized a workaround for the "View in PDF Reader", so I think we are all set now.
Good news by the way: the ability to merge PDF files together is already there. There is a function called "Utility_Merge_PDF" (or something like that).
More later!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 06 Jul 08 at 4:04PM
Hi Michel -
All sounds good! Look forward to the new release.
Yes, I knew merge capability is there (one reason why we liked it) but we may want to do some tricky merge stuff - but will have to wait until we get through this first PDF phase to get serious about it.
Happy Sunday! Rick
|
Posted By: Michel_K17
Date Posted: 06 Jul 08 at 11:55PM
Hi Rick,
Here you go. The download links that you will need are:
-
Upgrade to PDF reDirect Pro v2.2.6: [ http://www.exp-systems.com/PDFreDirect/Download/Upgd_PDFR_Pro_to_v226.exe - here ]
- Updated ActiveX and Sample VBA Code [ http://www.exp-systems.com/PDFreDirect/Download/VB_Sample_for_PDFR_Pro_v22006.exe - here ]
Be aware that the sample code in the Access demo has been extensively re-written, so, if you have already modified it with your own code, you may want to save a copy as the update will overwrite the existing file.
The sum total of the changes for v2.2.6 are modest because the other changes I have in the works are still in "beta" stage. Therefore, v2.2.6 is an "official" release and all of the executables have been digitally signed. Changes are:
- FIXED: Bugs in the ActiveX Component and the sample VBA Code
- FIXED: Bug in FTP Connection code which prevented connecting to an FTP account.
- IMPROVED: Added ANSI paper sizes to printer (requires full install)
- IMPROVED: quality of preview
When you look at the VBA code, you should find a couple new functions in the component, namely one to print PDF files, and the other to display a "SaveAs" dialog box so that you can find out the Filename the user wants to use. The sample code shows how to use the "SaveAs" function.
Let me know if you hit any snags. Hopefully not: I tested the code on Windows 2000 and XP machines successfully.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 07 Jul 08 at 1:44AM
Hi Michel -
Late session (central time)! Thanks for the update - sounds great - will try it in the AM and let you know. Thanks for the perseverance.
thx - Rick
|
Posted By: RickNTA
Date Posted: 07 Jul 08 at 11:16PM
Hi Michel -
OK - had a fragmented day but finally got through basic setup / testing and comprehending the changes in the sample code. I tested changes to the filename using Convert2Pdf() with Settings_Overwrite = OW_SAVEAS_DIALOG and the new Settings_Show_PDF = True, and also using your new Convert2PdfEx(). My conclusion: works great!
Thanks for getting the changes in place quickly!
Just a couple of questions for now:
1. Is Upgd_PDFR_Pro_to_v226.exe only for upgrading, or will it work for an initial install?
2. I had noticed this before: with Settings_Lock_Do_Not_Allow_Printing = False, the UI for the BatchPDF Preferences still has "Do not allow...High Resolution Printing" checked. I don't know what effect that has - should I be worried about it?
I'll get to integrating it more fully with our app in the next few days and will let you know if anything comes up - but so far, so good.
thx - Rick
|
Posted By: Michel_K17
Date Posted: 08 Jul 08 at 12:48AM
Hi Rick,
Glad to hear it!
Yes, the "pgd_PDFR_Pro_to_v226.exe" is solely for upgrading existing installations. You will want to full installation program for new users available [ http://www.exp-systems.com/PDFreDirect/Download/Install_PDFR_Pro_v226.exe - here ].
I think you asked the permissions questions once before, and forgot to look into it. I'll go investigate to see what is going on, and will get back to you.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 08 Jul 08 at 1:19PM
Hi Michel -
Thanks! Your "[here]" didn't have a live link - but for anyone reading this, just go to the sticky posts at the top of each forum section!
To clarify on the permissions / Settings_Lock_Do_Not_Allow_Printing issue: I think I had mentioned it before (although I can't find where!), but a week or so ago it was mixed in with the other issues so at one point it seemed like the basic locking (Settings_Locked) wasn't working. Now it's clear the basic locking is working (another feature we'll be using) and the only thing that's confusing me is the "Do not allow...High Resolution Printing" setting. May not be a big deal; I just wanted to be sure it's OK...
Hey - are you getting enough sleep?!
thx - Rick
|
Posted By: Michel_K17
Date Posted: 08 Jul 08 at 11:48PM
Hi, Oops. Sorry for the link.
I did indeed add the dual "no printing" security options in the main program - but as you noted, it is still missing in the ActiveX component. So, Settings_Lock_Do_Not_Allow_Printing, like you said, denies all printing.
What is missing in the ActiveX component is that you can choose to deny printing normally (High Rez), but still allow the user to print, but only in low resolution/fax quality output.
Hopefully this will be a bit clearer. If you want, you can check it out via the regular PDF reDirect Pro user interface >> Preferences >> Security, but basically, the ActiveX component's setting denies all printing.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 22 Jul 08 at 6:15PM
Hi Michel -
OK, I'm back into it after some diversions for a while, and have run into another problem: occasionally while printing (the DoCmd.OpenReport line in PrintOutputToBatchPrinter) the BatchPDF progress dialog shows "Error. Could not Create PDF" and the file isn't created. The problem is that it does this with the exact same report that's "printed" 10 or 20 times before that with no problems, and will print 30 seconds later with no problems - I have no clue as to why this happens. The LastDllError isn't getting set. Is there a way to get an error code returned by the BatchPDF, or some other way to trap and deal with the error at run time? I can force the same error message in the progress dialog by trying to create the same filename as a PDF file that's currently open in Adobe Reader, but the random error pops up with brand new file names under apparently normal circumstances. Help!
thx - Rick
|
Posted By: Michel_K17
Date Posted: 23 Jul 08 at 10:42AM
Hi Rick,
I agree with you that if the program is giving you an error message, then at least the error code should be set in LastDllError should be set. It'll be interesting to find out where the problem is coming from.
I will try to reproduce the problem here, and see what I get.
Does this problem occur as part of many reports being produced (for example, producing hundreds of PDF invoices), or is this where you convert just one report?
If I cannot reproduce the problem - I will send you a special version of the ActiveX component with error logging turned on so that we can see what is going on.
My support might be slow today. I am on vacation today (Seattle), and leaving in a couple of hours to go back to Kansas, and do not get there until 11:30 PM. I'll see what I can do before I leave.
Cheers!
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 23 Jul 08 at 11:35AM
Hi Michel -
It's just one report at a time - pretty small (mostly I've been testing with one that's about 8 pp long) with some variations in the data and thus the report size. Very intermittent problem (the worst kind!) with no obvious characteristics. Might be good to send the error-logging DLL.
Guess it's too late to say "we're not in Kansas anymore". Hope Seattle was good! Lots of coffee, huh?
thx - Rick
|
Posted By: Michel_K17
Date Posted: 23 Jul 08 at 1:03PM
Hi Rick,
Yes, lots of coffee (way too much actually). Weather cooperated which was nice.
So far, I have been unable to reproduce the problem. Manually, everything worked (tried about 40 times in a row).
I then setup an automated system, and produced 1,000 PDF files - again, without any problems.
Yes, I will get you that logging version of the library. I have an old one which I need to port over for you first, so I'll do that tomorrow as I am about to leave for the airport.
Catch you later,
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: Michel_K17
Date Posted: 27 Jul 08 at 6:49PM
Hi Rick,
It's turning out to be easier than I thought. I am going to guess that if the PDF is not properly created, it's
probably because of a problem in the PDF creation code (ie the core components to
PDF reDirect), and therefore nothing to do with the ActiveX component at
all (ie no special version needed)
Therefore, you can simply turn on the
error logging in PDF reDirect Pro (via the Preferences). Then test your
code until the problem occurs. When it finally does, re-open PDF
reDirect Pro, and turn off the error logging.
Next: you can:
-
use the bug submission button, or
- click the "view
log file" button, then copy-and-paste the log file into an e-mail, or
- click the "view
log file" button (to create the single combined log file), then attach the following file into an e-mail and send to me:
C:\Documents and Settings\[USERNAME]\Application Data\PDF reDirect\Bug_Reports\Log_Combined.txt
Note: If you use the bug submission tool, please post here or send me an e-mail to let me know as I do not check the server daily for these files.
I should have thought of that earlier. Sigh. :-)
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|
Posted By: RickNTA
Date Posted: 28 Jul 08 at 2:57PM
Hi Michel -
Thanks; that sounds good. I'm in the middle of some other stuff but will try to get to this today and get back to you.
thx - Rick
|
Posted By: RickNTA
Date Posted: 28 Jul 08 at 10:09PM
file:///C:%5CDOCUME%7E1%5CRickN%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml -
Hi Michel -
OK - just emailed you the error log - look forward to hearing from you - hope it's an easy one!
thx - Rick
|
Posted By: Michel_K17
Date Posted: 28 Jul 08 at 11:25PM
Hi Rick,
I sent you an updated executable with additional logging. Please give that a try - hopefully, it will provide the information that we need.
Thanks!
Michel
|
|