+ Reply to Thread
Results 1 to 7 of 7

Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for Mac

  1. #1
    Registered User
    Join Date
    01-13-2006
    Location
    Australia
    Posts
    8

    Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for Mac

    I am using Excel for Mac 2011 and do not know much about VBA or Macros

    I have a spreadsheet that references data from a data sheet (FBB Data) and places in a document for printing (FBB Print) sheet. I have a Macro that will cycle through the FBB data list, update the FBB Print sheet and print out a page for each line it reads. This works well when going to a printer. I have tried to modify the Macro below however so that it will save each document as a PDF in a specific file location (FBB Contracts folder). Each PDF needs a different name however and I am trying to select that from cell L4 eg the cell might be EGMOFF. So what I am trying to achieve is for the file to save as EGMOFF.PDF and save it in the FBB Contracts folder

    I am getting a debug error with the macro and I dont know how to fix it.
    I Know the file structure is different for a MAC and im not sure Ive got that completely right in the Macro.

    The debug error starts down the bottom of the Macro on the line that reads ActiveSheet.ExportAsFixed......

    Hope you can help solve why it wont work

    Thank you


    Sub Save_to_PDF()
    '
    ' Save_to_PDF Macro
    '
    Dim varResponse As Variant

    varResponse = MsgBox(" ", vbYesNo, "Are you certain you want to Save ALL FBB Contracts as PDF?")

    If varResponse <> vbYes Then Exit Sub

    RowCount = Worksheets("FBB Data").Cells(Rows.Count, 1).End(xlUp).Row - 1

    Worksheets("FBB Print").Select
    For i = 1 To RowCount
    Range("N1").Value = i
    pdfname = Range("L4").Value
    MyFN = "Mac SSD:Users:gemnnsw:Documents:FBB Contracts:" & pdfname & ".pdf"
    On Error Resume Next
    Kill (MyFN)
    On Error GoTo 0
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=MyFN, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False
    Next i
    '
    End Sub

  2. #2
    Registered User
    Join Date
    08-31-2015
    Location
    United States
    MS-Off Ver
    Mac 2011
    Posts
    12

    Re: Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for

    Hi gemnnsw,

    Use the below code for Save PDF
    Please Login or Register  to view this content.
    Last edited by thakrish; 09-03-2015 at 01:03 AM.
    If I have helped, click on the star below the post

  3. #3
    Registered User
    Join Date
    01-13-2006
    Location
    Australia
    Posts
    8

    Re: Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for

    Thanks for the reply

    It Runs but stops at the point where it starts ActiveSheet.Export
    I get an application defined Object defined error

    This is the same spot where the previous script stopped as well

    Any other ideas?

  4. #4
    Registered User
    Join Date
    08-31-2015
    Location
    United States
    MS-Off Ver
    Mac 2011
    Posts
    12

    Re: Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for

    The same script works for me. Could you share your workbook, let me check.

  5. #5
    Registered User
    Join Date
    01-13-2006
    Location
    Australia
    Posts
    8

    Re: Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for

    Here is a sample of the spreadsheet. The macros I am having trouble with is 'Save to PDF'. It contains the original Macro I used but as indicated even after changing to the macro you have provided it still gets stuck.

    Hope you can help

    Regards
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-31-2015
    Location
    United States
    MS-Off Ver
    Mac 2011
    Posts
    12

    Re: Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for

    Hi,

    Its resolved. Check the attached updated spreadsheet.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-13-2006
    Location
    Australia
    Posts
    8

    Re: Macro to save as PDF to file location selected from cell in spreadsheet-Excel 2011 for

    It is working very well. Thank you for the help

+ 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. [SOLVED] Macro to save selected worksheets as workbooks in variable location
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-25-2015, 10:32 AM
  2. Macro to Auto save a backup copy in a seperate location OR save file with a pop up
    By kdsanderson30 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-12-2014, 12:38 PM
  3. Replies: 1
    Last Post: 02-27-2014, 01:01 PM
  4. [SOLVED] Macro to save Excel file in multiple location
    By sidd913 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-11-2014, 01:45 PM
  5. [SOLVED] Macro to save a file to a certain location and name it after 2 cell values possible?
    By 33CDonnelly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 07:57 PM
  6. [SOLVED] Macro to Save File to Location Folder Based on Date in Cell
    By John_Day83 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2013, 05:34 PM
  7. [SOLVED] [Help]macro to open file browser, to select a location, and save the location to a cell
    By zhuleijia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2013, 09:56 AM

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