Announcement

Collapse
No announcement yet.

Excel for Mac: Set fs = CreateObject("Scripting.FileSystemObject") - runtimeerror 429

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Excel for Mac: Set fs = CreateObject("Scripting.FileSystemObject") - runtimeerror 429



    Set fs = CreateObject("Scripting.FileSystemObject") gives runtime error 429

    "activex component can't create object"

    the entire routine is to copy files from one directory to another, but I can't even get to the file stage, getting the error at Set fs = etc.....


    Sub CopyRenameFiles()

    Dim fs As Object, i As Integer
    Dim oldPath As String, newPath As String
    oldPath = "Macintosh HD:Users:macattack:Documents:My Documents:Dropbox:YesWeCan:Dog Supplies:_lncfiles:lncimages:" 'Folder file is located in
    newPath = "Macintosh HD::Users:macattack:Documents:My Documents:Dropbox:YesWeCan:Dog Supplies:_lncfiles:lncimagesunique:" 'Folder to copy file to
    Set fs = CreateObject("Scripting.FileSystemObject")
    i = 2
    Do While Cells(i, 3) <> ""
    If FileExists(oldPath & Cells(i, 3) & ".jpg") Then
    fs.CopyFile oldPath & Cells(i, 3) & ".jpg", newPath & Cells(i, 4) & ".jpg"
    Else
    fs.CopyFile oldPath & "comingsoon.jpg", newPath & Cells(i, 4) & ".jpg"
    End If
    i = i + 1
    Loop
    Set fs = Nothing




    End Sub






    Function FileExists(PathName As String) As Boolean

    Dim iTemp As Integer
    On Error Resume Next
    iTemp = GetAttr(PathName)
    Select Case Err.Number
    Case Is = 0
    FileExists = True
    Case Else
    FileExists = False
    End Select


    On Error GoTo 0
    End Function







    any help appreciated.


    MW
    • January 4, 2012
    • Reply with quote
    • Report abuse


    1 Person had
    this question
    Stop emails

    mischiefwizard

  • #2
    Re: Excel for Mac: Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot - runtimeerror

    mischiefwizard
    Ron May have a solution here .. probably a reference library missing ..
    If the solution helped please donate to RSPCA

    Sites worth visiting: Rabbitohs | Excel-it royUK | Excel Matters Rory | Kris' Spreadsheet Solutions | Domenic xl-central | SO The Macro Man | The Smallman

    Comment


    • #3


      Re: Excel for Mac: Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot - runtimeerror

      You can't use the Scripting Runtime on a Mac - it doesn't exist, so you will need either MacScript or to use Dir instead (simpler).
      Rory
      Theory is when you know something, but it doesnít work. Practice is when something works, but you donít know why. Programmers combine theory and practice: nothing works and they donít know why

      Comment

      Working...
      X