Results 1 to 14 of 14
  1. #1
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63

    Exporting Form to PDF - Output File Name

    Hello,

    I am trying to export my form to a PDF file. The export file needs to be unique, so it needs to include information selected in a combobox (called cboCustomerName) and a current timestamp. Is there a way that I can write a code to do this in the code builder?

    I was thinking "C:\Users\User1\Desktop\" & cboCustomerName & ".pdf" but this doesn't work.

    I have a form that a user will complete. When the user finishes filling out the form, I want them to click the "Submit" button. When the "Submit" button is clicked, I would like a screenshot of the form to be saved as a PDF file.

    Also, the PDF filename needs to be unique by pulling from fields that were filled out on the form and a time/date stamp. For example, one of the fields in my field is "Customer's Name". Assuming the customer's name is John Smith, the output file would be something like this:

    C:\Users\User1\Desktop\John Smith_5.26.2015_14:40.pdf



    I am not looking to generate a report that accomplishes this if possible.

    Thank you in advance.
    Last edited by June7; 05-27-2015 at 11:31 AM. Reason: Merge posts

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Do you mean a screen cap? or the data in the form?

  3. #3
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    essentially a screen capture exported to a pdf

    so I have a field with the customers name and I have a field with the current time and date. I want the screenshot to be captured, exported to pdf with this file name:

    C:\Users\User1\Desktop\ (customer's name field)_(current date)_(current time) .pdf
    Last edited by June7; 05-27-2015 at 11:32 AM.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Perhaps the solution is to export a Report to a PDF file instead of exporting a Form. Form's, as an object, are not very good candidates for exporting data. Reports will help to format and create an hierarchy.

    Also, when I think of a "screenshot" I think of an image. Although I believe this is possible to do from Access, I do not believe this is what you actually desire.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I would agree with ItsMe - a formatted report exported as a pdf is the way to go. To create a screen capture from Access would require using the Shell environment and I really think you do not want to go there. You would specify the path and file name in the export process. I figure the code would concatenate the needed form variables to the file path, something like & Me!txtCustName & "_" & Now(). I assume you'd run this from a form that has a command button and the fields whose values you want to use as part of the file name. You will have to consider the Windows Regional Settings for the users to get the exact format that you need for the date/time stamp, and based on what you've written, you may want to use the Format function on the Date() or Now() part to create a custom format that gives you the file name structure you want.

  6. #6
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    I'm not looking to create a report. I need to take a physical screenshot of what the user filled out and save it as a PDF with the click of a button. The file output needs to be unique which will grab from the fields that were filled out on the form and the timestamp when it was completed. For example: C:\Users\Cory\Desktop\John Smith_5.26.2015_14.23.pdf

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This topic already covered in your other thread. Threads merged.

    A screenshot is not the same as exporting/printing to PDF.

    A screenshot is a Windows operation and requires use of Shell and likely would be a jpg, not a PDF.

    Exporting to PDF can be done with OutputTo export method.

    Printing to PDF requires a PDF printer driver installed.

    With either approach, unless the form is filtered to the single record, all records will export/print.
    Last edited by June7; 05-27-2015 at 11:28 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    Thank you.

    Since the form is in data entry mode, it does not export all of the records, only the current record. Assuming I wanted to go the OutputTo route, how would I incorporate the fields on the actual form?

    I just tried this but it's failing:

    Private Sub SubmitButton_Click()
    DoCmd.OutputTo(acOutputForm,"Customer Data Form",acformatpdf, "C:\Users\E63430\Desktop\" & cboCustomerName.Value & ".pdf", , , ,acExportQualityPrint)
    End Sub
    Last edited by June7; 05-27-2015 at 11:29 AM.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What happens - error message, wrong results, nothing?

    Don't use the parentheses.
    Last edited by June7; 05-27-2015 at 11:35 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    Compile Error:

    Expected: =

    How do you mean without parenthesis?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    DoCmd.OutputTo acOutputForm, "Customer Data Form", acformatpdf, "C:\Users\E63430\Desktop\" & cboCustomerName.Value & ".pdf", , , ,acExportQualityPrint

    The parentheses make VBA expect a function. Functions must be on the right side of an expression.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    Negative - that didn't work. nothing's happening. Thank you anyway.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Tested and works for me. I don't know what the acExportQualityPrint is for and did not use that.

    Also, I did not save to Desktop but to C:\ root.
    Last edited by June7; 05-27-2015 at 11:34 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    We had a situation like this where I work. It was easy enough to export the report as a pdf, which is pretty much a picture of the text, and open a preformatted email message all set to go. However, management did not want a pdf attachment in the email - they wanted the picture of the report in the email. I guess they were too busy to open the pdf attachment. So the admin girl opens the report, uses Snagit to make a pic of the pdf, opens a new message and pastes it in. Takes her 3x longer to get a jpeg instead of a pdf (which as I say, is basically a picture anyway). So I looked into automating the pic creation part and all I could find was the Shell or Shell API functions with all their error prone methods. As I wrote this, it occurred to me that you might be able to control a third party screen capture program if you have the gumption to figure it out. I see that Snagit has a COM model that can be controlled with C#, C++, VB, VB.Net and VB scripting, but I have no experience with those languages. So if you're dead set against having a report, maybe you can find an app you can control. Try http://download.techsmith.com/snagit.../snagitcom.pdf. Also, by Googling "vba screen capture as pdf" I found links to using the PrintScreen utility to save window images in other forms, such as Word documents. If you are not stuck on pdf, maybe those could work for you.
    ***Came back abt 1 hr later after thinking of this: maybe you could create a VBA picture object (goes back to version 4) and print it with a pdf printer driver. If you are not familiar with that, it looks like any other printer type you have installed that is selectable from the installed printers list. I think it's an Adobe driver, but I'm not sure if you have to have an Adobe pdf creator license. It is in my installed printers list at work and I'm pretty sure I do not have the Adobe software to create pdfs.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Output Report to PDF file
    By jcc285 in forum Reports
    Replies: 4
    Last Post: 03-30-2015, 10:54 AM
  2. variable filepath for output file
    By Jaron in forum Programming
    Replies: 6
    Last Post: 07-31-2013, 06:26 PM
  3. output file name
    By AdrianoG87 in forum Reports
    Replies: 4
    Last Post: 11-03-2011, 06:20 PM
  4. Exporting and saving file as [FORM]![FORM1]![FILENAME]
    By Elbows in forum Import/Export Data
    Replies: 1
    Last Post: 10-18-2011, 10:02 AM
  5. How would you output an XML file with an Ole Attachment?
    By techneophyte in forum Programming
    Replies: 7
    Last Post: 09-09-2010, 09:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums