Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro works fine on PC; fails on Mac


Hi-

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

It works on a PC, but when I run it on my Mac, I get the followin
error: #VALUE!. Is there some element that has to be define
differently for Mac? Does anyone know how I can get this UDF to work o
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 Functio

--
marle
-----------------------------------------------------------------------
marlea's Profile: http://www.excelforum.com/member.php...fo&userid=2620
View this thread: http://www.excelforum.com/showthread.php?threadid=52454

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro fine Run fine from Select but not from KB Shortcut? [email protected] Excel Discussion (Misc queries) 8 August 31st 06 02:06 AM
Macro hangs up often but sometimes works fine Jeff Excel Worksheet Functions 3 June 13th 06 01:01 PM
Works fine in debug, but... DiBaco Excel Programming 5 February 24th 06 04:35 PM
Solver GUI works fine, but the VBA macro won't return any results Ben Anderson Excel Programming 3 June 24th 05 02:48 PM
Macro works fine in xl2002 but does not in xl 2000 Nolin[_2_] Excel Programming 1 February 25th 04 05:58 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"