+ Reply to Thread
Results 1 to 2 of 2

Macro works fine on PC; fails on Mac

  1. #1
    Registered User
    Join Date
    08-11-2005
    Posts
    24

    Macro works fine on PC; fails on Mac

    Hi-

    Someone on this board was kind enough to write the macro (user defined function) below for me. Its purpose is to search for file names in a desktop folder and return a true or false depending on whether or not a match is found in the folder.

    It works on a PC, but when I run it on my Mac, I get the following error: #VALUE!. Is there some element that has to be defined differently for Mac? Does anyone know how I can get this UDF to work on my Mac? Thank you!

    -------------
    Function FileInDeskFldr(fName As String) As Boolean

    Const Desktop = &H10&

    Dim strDsk As String
    Dim strFldrPath As String

    ' Find path to the Folder on the Desktop
    Set objShell = CreateObject("Shell.Application")
    Set objFolderDsk = objShell.Namespace(Desktop)
    strDsk = objFolderDsk.Self.Path
    strFldrPath = strDsk & "\Test"

    ' Verify existence of named file in the Desktop Folder
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(strFldrPath & "\" & fName) Then
    FileInDeskFldr = True
    Else
    FileInDeskFldr = False
    End If

    Set objFolderDsk = Nothing
    Set objShell = Nothing
    Set objFSO = Nothing

    End Function

  2. #2
    Jim Cone
    Guest

    Re: Macro works fine on PC; fails on Mac

    marlea,

    The Shell function is not available on Macintosh versions earlier than System 7.0
    The FileSystemObject requires Windows.

    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware



    "marlea" wrote in message...
    Hi-
    Someone on this board was kind enough to write the macro (user defined
    function) below for me. Its purpose is to search for file names in a
    desktop folder and return a true or false depending on whether or not a
    match is found in the folder.

    It works on a PC, but when I run it on my Mac, I get the following
    error: #VALUE!. Is there some element that has to be defined
    differently for Mac? Does anyone know how I can get this UDF to work on
    my Mac? Thank you!

    -------------
    Function FileInDeskFldr(fName As String) As Boolean

    Const Desktop = &H10&

    Dim strDsk As String
    Dim strFldrPath As String

    ' Find path to the Folder on the Desktop
    Set objShell = CreateObject("Shell.Application")
    Set objFolderDsk = objShell.Namespace(Desktop)
    strDsk = objFolderDsk.Self.Path
    strFldrPath = strDsk & "\Test"

    ' Verify existence of named file in the Desktop Folder
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(strFldrPath & "\" & fName) Then
    FileInDeskFldr = True
    Else
    FileInDeskFldr = False
    End If

    Set objFolderDsk = Nothing
    Set objShell = Nothing
    Set objFSO = Nothing

    End Function
    --
    marlea

+ 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