Results 1 to 6 of 6

Thread: Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2015
    Posts
    2

    Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

    Hi everybody – hope you can help me out.

    I ‘m working on an Access tool (2007/VB6.5) which I’ve got the beginning and end of sorted. I’ve spent days scouring the internet for the solution to the middle bit to no avail, so I’d really appreciate some expert help:

    PART ONE : produce an Access report populated by fields from an imported spreadsheet, export as a single-page PDF; (I have this part completed and working beautifully!)

    PART TWO - NEED HELP WITH CODE TO:
    1. take a pre-existing multi-page PDF document and ‘print’ to the ‘Microsoft XPS Document Writer’;
    2. open this XPS document in ‘XPS Viewer’ and ‘print’ to ‘Adobe PDF’

    PART THREE: Insert the single-page PDF (the result of Part One) into the multi-page PDF at Page 2 (I have this part completed and working beautifully, too!)

    The reason I need to do this odd little dance-around is that the pre-existing documents are reports that have a long-forgotten password on them so they are uneditable (i.e. you can’t “Insert From File” within Adobe Acrobat X Standard). It seems that by ‘printing’ to XPS and then ‘printing’ again to PDF gets around this annoyance and I end up with a multi-page document that will allow the automation of Part 3.

    I believe I found a chink of light in this link, but it’s .NET code which I cannot work with.
    http://www.aspose.com/docs/display/p...nter+(Facades)

    I am a novice at best. Please be kind!
    Thanks for reading this far.
    All the best,
    Jonathan

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,454

    Re: Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

    This belongs in the Office Development section...(VB6.5 is VBA).....I'll ask a moderator to move it.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,972

    Re: Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

    part 2, 1 is easy enough, just use shellexceute API, there will be many examples for this, in this forum and google, with the print verb, having first changed the windows default printer to xps document printer, change back afterwards

    part 2, 2
    for a free 3rd party tool to print xps files see http://www.frogmorecs.com/content/downloads/
    you probably need to use shell to run it from your VBA
    there maybe plenty of other options, this was the first hit i got in google

    edit: part 1 may also require some 3rd party help to avoid the pop up dialog for the XPS file name frogmore also has a solution for this, or some code examples are available to automate the filling of the pop up dialog, this is not possible directly in VBA, but can be done by creating an instance of some other VBA application, or a compiled exe, which can monitor for the popup and complete, messy but can work, a 3rd party solution may be better

    is it not possible to do this once manually, saving the resultant pdf without password for future use
    Last edited by westconn1; Feb 21st, 2015 at 01:50 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,453

    Re: Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

    Besides the fact that this is not a VB question, but an Office VBA question and thus in the wrong forum....

    The site's terms of use do not permit discussions of hacking techniques, which is what you are requesting help with. Excuses like "well it is just for my own use with... yeah, yeah, that's the ticket, my own stuff" don't fly.

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,615

    Re: Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

    As Dilettante points out, we won't help you bypass passwords.

    I am somewhat bemused, though. If the document is password protected I wouldn't expect you to be able to even print the document in the first place. If you can print the document, why not just create a new document with the same layout and content. I can't see any need to jump through the hoops you appear to be jumping through.


    edit> Also, moved to VBA
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2015
    Posts
    2

    Re: Printing a PDF to 'Microsoft XPS Document Writer' using VB6.5

    Thanks, westconn1 for your suggestions; I'll look into them.

    Apologies to everyone else (even the sarcastic ones!) for appearing to circumvent the usual way of doing things. I have my company's complete permission (and request!) to do this. The documents are only protected from editing, not printing - created by consultants who were employed to do some work for us. We own the documents and all the content. This is just a way of inserting a 'status' sheet of how confident we are of the documents' correctness at this time, despite them being 7+ years old. The people who once had the passwords have moved on and this will save having to contact consultants again (who have probably also moved on!).

    Thank you, anyway. I'm sure none of you would even think of using such a method now that I've informed you of it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width