LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Filesearch in Remotely Called Macro

Hello,
I'm using WSH to call a vbs script on a remote machine that launches Excel
and calls a stored macro. The script successfully launches and the macro is
successfully run.

However, within this macro, I use FileSearch to query a directory on a
shared file sever. When I run the vbs script locally, the FileSearch
executes correctly and FileSearch returns all files in the directory.
However, when I launch the script remotely, .Execute returns 0 and the macro
is done. In both cases, the Dir method returns that the path is valid, so it
doesn't seem to be an issue with visibility to the directory or server. I've
pasted the macro code below.

Any ideas why FileSearch wouldn't execute in a macro that is called remotely?

Many Thanks! Pat



Public Sub TestMacro()
' LogInformation is a call to a sub that logs to a text file

On Error Resume Next


Const workingDir As String = "\\servername\path\to\directory\"

If Dir(workingDir, vbDirectory) < "" Then
LogInformation ("Path is VALID")
Else
LogInformation ("Path is NOT VALID")
End If


' Search for xls files within workingDir
With Application.FileSearch
.NewSearch
.LookIn = workingDir
.SearchSubFolders = False
.fileName = "*.*"

LogInformation ("Found Files?")

'If you find files, do what we came here for
If .Execute() 0 Then

LogInformation ("Found Files: True")

For i = 1 To .FoundFiles.Count

LogInformation ("File " & i & ": " & .FoundFiles(i))

Next i

Else
LogInformation ("Found Files: False")
End If

End With

End Sub

 
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
Calling Excel macro remotely? Maury Markowitz Excel Programming 6 January 5th 05 08:21 PM
Worksheet_Change sub does not trigger a called macro herman Excel Programming 3 February 8th 04 08:30 PM
Keeping name of worksheet who called macro Dkline[_2_] Excel Programming 3 January 30th 04 06:40 PM
which FormField called a macro? Juggernath[_2_] Excel Programming 0 January 15th 04 12:58 PM
FileSearch macro returning incorrect docs? Ed[_9_] Excel Programming 2 December 10th 03 05:48 PM


All times are GMT +1. The time now is 02:08 PM.

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

About Us

"It's about Microsoft Excel"