+ Reply to Thread
Results 1 to 2 of 2

Macro to save file as pdf that will work on both PC and Mac

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365 MS and mac
    Posts
    26

    Macro to save file as pdf that will work on both PC and Mac

    I have a workbook that will be used by multiple users on both PC and Mac.

    The objective is to produce a customer quote that can either be printed and e-mailed as a pdf attachment.

    The workbook has two worksheets - "Input" and "Quote". All input field are on the Input Sheet and the actual quote is on the Quote sheet which is hidden.

    My print macro works OK but my save macro does not. The filename that the pdf is to be saved under is generated from the customers name (an input field) together with the date and is in a cell named "File_Name". The file is to be saved on the user's desktop.

    Thanks in anticipation. ..Rick

    This is the macro I have.

    Please Login or Register  to view this content.
    Last edited by arlu1201; 02-11-2013 at 04:43 AM. Reason: Use code tags

  2. #2
    Registered User
    Join Date
    10-05-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365 MS and mac
    Posts
    26

    Re: Macro to save file as pdf that will work on both PC and Mac

    I managed to work this and have included the corrected code below in case this is of any use to anyone.

    Thanks

    Sub Quote_Save()
    '
    ' Quote_Save Macro
    ' Save pdf invoice
    '
    ' Keyboard Shortcut: Option+Cmd+Shift+B
    '

    Dim DTAddress As String
    Dim FileName As String
    Dim FullyQualifiedFileName As String

    'Unhide and select Quote sheet
    Sheets("Input").Select
    Sheets("Quote").Visible = True
    Sheets("Quote").Select

    'Get the path to the User's Desktop
    DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator

    'File Name
    FileName = Range("File_Name").Value

    'Build the fully-qualified Workbook "save" path
    FullyQualifiedFileName = DTAddress & FileName

    'Switch Off all Application alerts before saving (in case the file already exists etc.)
    Application.DisplayAlerts = False

    'Save the current active sheet as a PDF file to the user's Desktop
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullyQualifiedFileName, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False

    'Hide Quote sheet
    ActiveWindow.SelectedSheets.Visible = False

    'Switch all Application alerts back on before exiting
    Application.DisplayAlerts = True

    End Sub

+ 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