trying to add 2 cells to a save as pdf file
Results 1 to 8 of 8

Thread: trying to add 2 cells to a save as pdf file
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default trying to add 2 cells to a save as pdf file

    Hi,

    his s the code I am using but where it says =range("C5") I want to add another cell like H1 but I must be blind and can not find it on here. I have tried multiple ways but just cant figure it out. sorry

    Sub saveaspdf()
    ChDir "C:\Users\he138642\Desktop\Test INVOICE"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("C5").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

    End Sub

  2. #2
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    Not tested, but it should work:
    Code:
    Sub saveaspdf()
    ChDir "C:\Users\he138642\Desktop\Test INVOICE"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("C5").Value & Range("H1").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
    
    End Sub
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  3. #3
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    ... or if you want a space character between the two strings...
    Code:
    Sub saveaspdf()ChDir "C:\Users\he138642\Desktop\Test INVOICE"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("C5").Value & " " & Range("H1").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
    
    End Sub
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  4. #4
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    Sorry - that should have been:
    Code:
    Sub saveaspdf()
    ChDir "C:\Users\he138642\Desktop\Test INVOICE"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("C5").Value & " " & Range("H1").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
    
    End Sub
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  5. #5
    New Member
    Join Date
    Jul 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    Thankyou so much that worked perfectly

  6. #6
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    You're welcome. Glad it worked for you, and thanks for the feedback.

    By the way - I failed to notice that this was your first post here, so Welcome to Mr. Excel! It's a superb resource - probably the most comprehensive out there - with some VERY switched-on folk here to help... of which I'm not one. I'm on the "B" team!
    Enjoy!
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  7. #7
    New Member
    Join Date
    Jul 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    yeah I have only just started and finding it fun to play with. I have this code which im playing with now but would you know how I can attach the email. thinking im missing something like labelling my saveas filename so I can use that name in the .attachments. Add filename. but no I a hurry as 'm getting to it when I can to play with it. It does everything I want it t do just wont attach .PDF


    Sub EMAIL()
    ChDir "C:\Users\he138642\Desktop\Test INVOICE"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("C5").Value & " " & Range("H1").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
    On Error Resume Next
    Dim OutApp As Variant
    Dim OutMail As Variant
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
    .To = Range("E7")
    .Subject = "Invoice From Peter Fleer Electrical"
    .Body = "Attached is the invoice from peter fleer electrical services" & Chr(13) & Chr(13) & "Kind Regards," & Chr(13) & "Peter Fleer." & Chr(13) & "0498 711 663."
    On Error Resume Next
    .attachments.Add Filename
    .Save
    .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub

  8. #8
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: trying to add 2 cells to a save as pdf file

    Something like this should work:
    Code:
    On Error Resume Next
    .attachments.Add "C:\Users\he138642\Desktop\Test INVOICE" & Range("C5").Value & " " & Range("H1").Value
    .Save
    .Display
    End With
    On Error GoTo 0
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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