Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Macro works fine on PC; fails on Mac

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
marlea - 20 Mar 2006 21:09 GMT
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
Jim Cone - 20 Mar 2006 21:26 GMT
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
Signature

marlea

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.