Results 1 to 6 of 6
  1. #1
    Wrangler is offline Wrangler
    Windows 7 Access 2007
    Join Date
    Dec 2005
    Location
    Alabama
    Posts
    17

    VBA code to print a report saved as a PDF

    I am doing an inventory database and have it setup so once you verify the inventory you can sign the form with the name and date, then it saves it to a PDF file using the inventory location and date.

    After that I used the web browser control to view the PDF.



    I am trying to setup a button to print the PDF that is viewed in the web browser control.

    Any ideas?

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Where are the pdf's - in the db or on a server? You want to print this some time after it was created, or perhaps at the same time? You're actually creating a pdf from a form and not a report? If stored on a server, you must be storing the file path in a table, yes? If not, you should be, then you'd be able to print it out by way of its file path.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Wrangler is offline Wrangler
    Windows 7 Access 2007
    Join Date
    Dec 2005
    Location
    Alabama
    Posts
    17
    The saved off PDFs are on a server. They are used as a reference. I would like to be able to print the after they have been stored so when we have to verify an inventory we can print it off. I do have the file path stored but not the file name. I have a button that I created that open the saved file using the:

    Dim File As FileDialog
    Set File = Application.FileDialog(msoFileDialogFilePicker)

    File.AllowMultiSelect = False
    File.InitialFileName = "server folder location"

    If File.Show Then

    Me.txtfileLocation = File.SelectedItems.Item(1)
    End If



    What I want to do is once I open the file in the web browser control if I want to print it I can have a button that uses the File.SelectedItems.Item(1) or the Me.txtfileLocation.value to print the file.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You say you don't have the file name as part of the path, yet you can display the file in a web browser. For that, do you not need the complete path? Rather than use filedialog to find a file associated with a record, I'd use the path property that you've set for the browser control, or at least store the complete path when you create it and print from the form record. There's likely a lot of questions answered with code samples so not much sense in repeating here. Here's one - replace loop portion with the path that I'm guessing has to be visible to the form seeing as how it's being displayed in a browser control.
    post 2 or 4 - note that 2 contains the ptr safe parameters, which are not repeated in post 4. Best to include that portion.
    https://www.access-programmers.co.uk...f-file.287501/

    or
    https://www.accessforums.net/showthread.php?t=61120
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Wrangler is offline Wrangler
    Windows 7 Access 2007
    Join Date
    Dec 2005
    Location
    Alabama
    Posts
    17
    Thanks a bunch I appreciate the help.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You're welcome. Post back if you get stuck.
    Good luck!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. report print preview blocking VBA code
    By Jeans in forum Reports
    Replies: 9
    Last Post: 02-27-2021, 09:57 AM
  2. Replies: 5
    Last Post: 08-06-2015, 03:26 PM
  3. Replies: 1
    Last Post: 02-21-2015, 11:35 PM
  4. Replies: 4
    Last Post: 06-05-2014, 02:24 PM
  5. code to print just first page of a report
    By tonyrice in forum Reports
    Replies: 1
    Last Post: 02-14-2007, 03:07 PM

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