+ Reply to Thread
Results 1 to 9 of 9

Converting VBA to mac (runtime error 429)

Hybrid View

Liset Converting VBA to mac... 07-23-2015, 06:22 AM
Kyle123 Re: Converting VBA to mac... 07-23-2015, 06:24 AM
Liset Re: Converting VBA to mac... 07-23-2015, 06:46 AM
Liset Re: Converting VBA to mac... 07-23-2015, 06:29 AM
Kyle123 Re: Converting VBA to mac... 07-23-2015, 06:38 AM
Kyle123 Re: Converting VBA to mac... 07-23-2015, 06:52 AM
Liset Re: Converting VBA to mac... 07-23-2015, 07:23 AM
Liset Re: Converting VBA to mac... 07-23-2015, 10:09 AM
Liset Re: Converting VBA to mac... 07-25-2015, 08:14 AM
  1. #1
    Registered User
    Join Date
    07-23-2015
    Location
    Nederland
    MS-Off Ver
    mac 2004
    Posts
    6

    Converting VBA to mac (runtime error 429)

    Hi all!
    I'm a beginner in coding. But I managed to make a working code for windows, but when I want to convert it to Mac it gave a runtime error 429 (AvtiveX component can't create object). This is the code that gave the error:

    Function FactuurOpslaan()
        Dim stPath As String
        With Sheets("Factuur Opstellen")
            stPath = ActiveWorkbook.Path & "\Facturen\"
            stPath = stPath & "Facturen" & Space(1) & MaandNaam(Month(Now)) & "-" & Year(Now)
            With CreateObject("Scripting.FileSystemObject")
                 If Not .FolderExists(stPath) Then .CreateFolder stPath
            End With
    .ExportAsFixedFormat 0, stPath & "\Factuur " & .Range("F29") & ".pdf", , 1
        End With
    End Function
    The error is in the "With CreateObject("Scripting.FileSystemObject")" part. Already from google search I found out that Scripting.FileSystemObject is only supported by windows, and will never work on a Mac. But I don't know how to fix it. Hope you can help me!

    Kind regards

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Converting VBA to mac (runtime error 429)

    You can't use windows libraries on a mac (pretty much anything that requires you to set a reference or use CreateObject).

    I think Dir should work though, so you can use that to check if something exists - also mkDir for creating folders

  3. #3
    Registered User
    Join Date
    07-23-2015
    Location
    Nederland
    MS-Off Ver
    mac 2004
    Posts
    6

    Re: Converting VBA to mac (runtime error 429)

    Thanks for helping me out!
    In the line of If not Len(Dir(stpath...) the error 68 occurs (device unavailable).

    Is it needed to define vbDirectory?
    Last edited by Liset; 07-23-2015 at 06:49 AM.

  4. #4
    Registered User
    Join Date
    07-23-2015
    Location
    Nederland
    MS-Off Ver
    mac 2004
    Posts
    6

    Re: Converting VBA to mac (runtime error 429)

    But do I only change the part of CreateObject("Scripting.FileSystemObject") with the Dir function? Or should I adjust the whole thing?
    I already read about the Dir function, but didn't know how to implement it....

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Converting VBA to mac (runtime error 429)

    I think this should be cross platform, but it's untested:
        Dim stPath As String
        With Sheets("Factuur Opstellen")
            stPath = ActiveWorkbook.Path & Application.PathSeparator & "Facturen" & Application.PathSeparator
            stPath = stPath & "Facturen" & Space(1) & MaandNaam(Month(Now)) & "-" & Year(Now)
            If Not Len(Dir(stPath, vbDirectory)) > 0 Then
                MkDir stPath
            End If
    
            .ExportAsFixedFormat 0, stPath & Application.PathSeparator & "Factuur " & .Range("F29") & ".pdf", , 1
        End With

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Converting VBA to mac (runtime error 429)

    Does Dir with the file path work? Remember that macs don't use the same path separators as windows

  7. #7
    Registered User
    Join Date
    07-23-2015
    Location
    Nederland
    MS-Off Ver
    mac 2004
    Posts
    6

    Re: Converting VBA to mac (runtime error 429)

    If I put it this way it still can't find its path
    Function FactuurOpslaan()
        Dim stPath As String
        With Sheets("Factuur Opstellen")
            stPath = "Macintosh HD:Users:christiaanpeelen:Documents:Factuursysteem:"
            stPath = stPath & "Facturen" & Space(1) & MaandNaam(Month(Now)) & "-" & Year(Now)
            If Not Len(Dir(stPath, vbDirectory)) > 0 Then
                MkDir stPath
            End If
    
            .ExportAsFixedFormat 0, stPath & Application.PathSeparator & "Factuur " & .Range("F29") & ".pdf", , 1
        End With
    End Function

  8. #8
    Registered User
    Join Date
    07-23-2015
    Location
    Nederland
    MS-Off Ver
    mac 2004
    Posts
    6

    Re: Converting VBA to mac (runtime error 429)

    Function FactuurOpslaan()
        Dim stPath As String
        Dim stsPath As String
        With Sheets("Factuur Opstellen")
            stPath = ActiveWorkbook.Path & ":Facturen"
            stPath = stPath & "Facturen" & Space(1) & MaandNaam(Month(Now)) & "-" & Year(Now)
            If Not Len(Dir(stPath, vbDirectory)) > 0 Then
                MkDir stPath
            End If
            .ExportAsFixedFormat 0, stPath & Application.PathSeparator & "Factuur " & .Range("F29") & ".pdf", , 1
        End With
    End Function
    This still gives the error of unavailable device... Good thing, it can find its path! Is something like MacID a solution?
    Last edited by Liset; 07-23-2015 at 11:53 AM.

  9. #9
    Registered User
    Join Date
    07-23-2015
    Location
    Nederland
    MS-Off Ver
    mac 2004
    Posts
    6

    Re: Converting VBA to mac (runtime error 429)

    Still a little bit desperate on the problem over here. I think that it may be caused by an empty folder, but how can I avoid this error then? Hope you can help me out!

+ 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. Runtime error '1004': Paste special method of range class error.
    By Daryl Zer0 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-05-2014, 01:44 AM
  2. [SOLVED] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  3. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  4. Defining Array - Runtime error 9, Subscript out of range error
    By MaartenW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2012, 07:32 AM
  5. runtime error 3265 error in a VBA Query to pull info from ERP Database
    By NBVC in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-12-2010, 03:59 PM
  6. Excel xmlHTTP object error message - system/runtime error
    By Porky2007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2007, 09:36 AM
  7. Excel 2003 Macro Error - Runtime error 1004
    By Cow in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 09:05 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