• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

OS to Mac Code Conversion

Spacey88

New Member
Hi I wrote the code (Got a fair bit of help off forums) for some macros on OS only to find they don't work on Mac. Did some digging I think I'm right in saying Mac uses a different version of VBA. Anyways I'm aware I'll have to rewrite the code for Mac but really struggling to find any help online. Here is the code for OS anyone got any advice on where to start?


>>> use code - tags <<<
Code:
Sub BRRRSnapshot()

Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler

Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
strTime = Format(Now(), "yyyymmdd\_hhmm")


    Sheets("Sheet1").Select
    Range("A1:X40").Select


strFile = strName & "_" & strTime & ".pdf"
strPathFile = strPath & strFile


myFile = Application.GetSaveAsFilename _
    (InitialFileName:=strPathFile, _
        FileFilter:="PDF Files (*.pdf), *.pdf", _
        Title:="Save SnapShot To")


If myFile <> "False" Then
    Selection.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        FileName:=myFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=True
   
    MsgBox "BRRR Snapshot saved to PDF:" _
      & vbCrLf _
      & myFile
End If

Sheets("Master").Select

exitHandler:
    Exit Sub
errHandler:
    MsgBox "Could not create PDF file"
    Resume exitHandler

TIA
 
Last edited by a moderator:

Spacey88

Did You test Your above part of code somewhere?
eg what is value for strname?

At least one part of above code should modify as below:
Code:
Sub DefaultGetSaveAsFilenameExampleOnMac()
'InitialFileName is the only parameter that is working on the Mac
    Dim FName As Variant
    FName = Application.GetSaveAsFilename(InitialFileName:="MyTestName")    
    If FName <> False Then
        MsgBox "You can use this path to Save now: " & FName
    End If
End Sub
 
Okay, if You write that it works with OS.
What about strname[(icode]?
... it's empty.
You should able to modify Your code as my pasted sample.
... as that code and link 'says'- Your somewhere gotten code has many parameters, which works only with OS.
 
Back
Top