+ Reply to Thread
Results 1 to 9 of 9

Show sheet as a PDF file

Hybrid View

Oeysbrei Show sheet as a PDF file 05-01-2012, 06:16 PM
Paul Re: Show sheet as a PDF file 05-01-2012, 06:40 PM
Oeysbrei Re: Show sheet as a PDF file 05-02-2012, 09:21 AM
Oeysbrei Re: Show sheet as a PDF file 05-02-2012, 01:39 PM
Paul Re: Show sheet as a PDF file 05-02-2012, 03:17 PM
Oeysbrei Re: Show sheet as a PDF file 05-02-2012, 04:09 PM
Oeysbrei Re: Show sheet as a PDF file 05-02-2012, 03:40 PM
Paul Re: Show sheet as a PDF file 05-02-2012, 04:14 PM
Oeysbrei Re: Show sheet as a PDF file 05-02-2012, 04:21 PM
  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Show sheet as a PDF file

    Hello,

    Is there a code I can use to show a a sheet from my workbook as a single PDF file by pressing a button from another sheet?

    Regards
    Oeysbrei

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Show sheet as a PDF file

    Perhaps see either of these sites for instructions:

    http://www.rondebruin.nl/pdf.htm

    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    (Ron is the author of both pages, and provides many examples of working with Excel.)

  3. #3
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Show sheet as a PDF file

    Thanks for youre reply.

    I have only been working with VBA and macros for a few months, so the code from the posted websites dident make sence to me.
    Does anybody have a code for this purpose that will only open a selected sheet from a workbook as a PDF file.

    Regards
    Oeysbrei

  4. #4
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Show sheet as a PDF file

    Hi,

    I have this code that makes me save a single sheet in a PDF format.
    What I need is the saved file to be opened after saved. What more do I need to add to this code to make it perform this task.

    Private Sub CommandButton2_Click()
    Static FileCount As Long
    Ark5.SaveAs Filename:="C:\Users\Oystein\Desktop\BTF\Hovedprosjekt\Exel prosjekt\Rapport\" & "BBA" & FileCount + 1 & ".pdf"
    FileCount = FileCount + 1
    
    End Sub
    When I try to open this file manually, I get a message that tells me it cant get opened because the format is not supported.
    Is there a way I can solv this?

    Regards
    Oeysbrei

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Show sheet as a PDF file

    If you record a macro of you saving a worksheet as a PDF you'll see the code that you need to adjust to fit your model.
    Private Sub CommandButton2_Click()
    Static FileCount As Long
    Sheets("Sheet1").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\Users\Oystein\Desktop\BTF\Hovedprosjekt\Exel prosjekt\Rapport\BBA" & FileCount + 1 & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    FileCount = FileCount + 1
    End Sub
    Edit your sheet name (or variable.. Ark5?) as needed.

  6. #6
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Show sheet as a PDF file

    Paul,

    It worked perfect once, but after that I get an error wile it tryes to open the file. The error is in adobe and tells me access denied.
    Do you have any idea why?

    Regards
    Oeysbrei

  7. #7
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Show sheet as a PDF file

    Paul,

    THANK YOU, it worked perfect.
    Now the rest will be a walk in the park until next project.

    Regards
    Oeysbrei

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Show sheet as a PDF file

    Unfortunately I don't know the reason. It is working for me in my simple test workbook without error. I can press the button to create a file, it opens, and whether or not I close the file I can press the button again and it creates another file (and opens it).

  9. #9
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Show sheet as a PDF file

    Paul,

    The file opens fine when I open it from were it´s saved, so it´s a mystery.
    I guess I will have to try update adobe.

    Thanks

    Oeysbrei

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1