Consulting

Results 1 to 2 of 2

Thread: Mac VBA to create a folder and print pdfs in folder

  1. #1

    Mac VBA to create a folder and print pdfs in folder

    I have the following code written and working on a PC, but I need it to work on a Mac. I am not a Mac user, so I do not know the differences in VBA coding on a Mac vs. PC. I need the code to cycle through a list from one sheet to fill in and print a 2nd sheet to pdf. There will be around 300 different pdfs that I need created in a new folder in the same location as the spreadsheet. The line of code it is currently hanging up on is the set fdObj, but I'm not sure what else will not run correctly on a Mac. Thanks for any help

    Option Explicit
    
    Sub PrintAnnual()
    
    Dim i, j, holder, fin
        
    Sheets("Invoice").Activate
    Worksheets("Invoice").Range("C11").Value = "December"
    
    Dim WS_Total As Integer
    WS_Total = ActiveWorkbook.Worksheets.Count - 2
    fin = Worksheets(WS_Total).Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count - 1
    
    Dim folder As String
    folder = ActiveWorkbook.Path + "\Year End Invoices\"
    
    Dim fdObj As Object
    Application.ScreenUpdating = False
    Set fdObj = CreateObject("Scripting.FileSystemObject")
    
    fdObj.CreateFolder (folder)
    
    Application.ScreenUpdating = True
    
    For j = 2 To fin
    
        Worksheets("Invoice").Range("C9").Value = Worksheets(WS_Total).Cells(j, 1)
        Sheets("Invoice").Activate
        ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=folder + Worksheets("Invoice").Range("C9") + " Year End Invoice", _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=False, _
            IgnorePrintAreas:=False, _
            From:=1, _
            To:=1, _
            OpenAfterPublish:=False
    
    Next j
    
    End Sub

  2. #2
    Check the May-June 2018 items at this website:

    http://www.rondebruin.nl/whatsnew.htm

    There's lots of good stuff elsewhere on that site too!

Posting Permissions

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