+ Reply to Thread
Results 1 to 4 of 4

Save Ranges to PDF Macro Any help is appreciated....

Hybrid View

  1. #1
    Registered User
    Join Date
    01-11-2016
    Location
    USA
    MS-Off Ver
    2007
    Posts
    22

    Save Ranges to PDF Macro Any help is appreciated....

    I had this code working with no problem, now it's giving me an error '1004' Document not Saved. Document may be open, or an error may have occured when saving. Don't know where I went wrong...any help is appreciated.

    [CODE]
    Sub savetopdf()'
    ' savetopdf Macro
    '
    Dim saveFileName As String
    Dim PDFranges As Range

    With ActiveSheet
    saveFileName = CreateObject("WScript.Shell").SpecialFolders("MyDocuments") & .Range("T3").Value & ".pdf"

    Set PDFranges = .Range("X3:AC48,AE3:AJ48,AL3:AQ48,AS3:AX48,AA59:AF104,AH59:AM104,AO59:AT104")
    End With

    PDFranges.ExportAsFixedFormat Type:=xlTypePDF, Filename:=saveFileName, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    '
    End Sub
    [CODE]

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Save Ranges to PDF Macro Any help is appreciated....

    It worked for me, so I am guessing your issue is with:
    saveFileName = CreateObject("WScript.Shell").SpecialFolders("MyDocuments") & .Range("T3").Value & ".pdf"
    Maybe you can try something like this instead:
    saveFileName = "C:\Users\" & Environ("UserName") & "\Documents" & .Range("T3").Value & ".pdf"
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Registered User
    Join Date
    01-11-2016
    Location
    USA
    MS-Off Ver
    2007
    Posts
    22

    Re: Save Ranges to PDF Macro Any help is appreciated....

    The error occurs as seen in the attached pic. (Again, at one point this was working fine.)
    I tried your solution, but have the same outcome.

    Please, any help is appreciated.
    Excel Problem.png

    Thanks!

  4. #4
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Save Ranges to PDF Macro Any help is appreciated....

    Can you post the file?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using VBA to save a Webpage as a PDF? Help Appreciated
    By Matty5894 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2015, 11:56 AM
  2. Save Ranges in Array
    By h0ps in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2014, 07:57 AM
  3. VBA Macro to copy data between sheets (Any help is appreciated)
    By oz12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-29-2013, 03:47 AM
  4. Export Excel Ranges to Word bookmarks using VBA then save word doc based on excel ranges
    By CuddlyGoldfish in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-30-2013, 07:47 PM
  5. Database search macro customization! Any support appreciated!
    By philips in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-27-2012, 06:50 AM
  6. Macro or Formula needed - Help much appreciated.
    By Benhouse86 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2012, 07:10 AM
  7. [SOLVED] how to save ranges into a running file...
    By RompStar in forum Excel General
    Replies: 47
    Last Post: 05-23-2005, 03:06 PM

Tags for this Thread

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