Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,469
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Saving a file under VBA with cell reference

    In my macro I have this code that doesn't work.
    Code:
    Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Users\JOE\CompanyDocs\" & Range(A5).Value & ".pdf" _
            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
            :=False, OpenAfterPublish:=False
    A5 is a concatenation of a text name from one cell and a number from another. E.G., "JohnBrown1"

    What's wrong with this? I tried .text and .value and both fail.
    Last edited by RetiredGeek; 2015-11-20 at 20:36. Reason: Added code tags

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    K.W.,

    Code:
    Sub PrtPDF()
    
      Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "G:\BEKDocs\" & Range("A5").Value & ".pdf", _
            Quality:=xlQualityStandard, IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, OpenAfterPublish:=False
            
    End Sub 'PrtPDF
    Tested OK!

    Note: the quotes around the Range("A5").Value & ".pdf

    HTH
    Last edited by RetiredGeek; 2015-11-20 at 20:44.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,469
    Thanks
    30
    Thanked 62 Times in 58 Posts
    Thanks, RG. Those little quotes mean a lot! GROAN. But, I'm learning!

Posting Permissions

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