Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Code To find and run an EXE file out side of the Excel

Hi,

I need to run another software ( like an EXE file) from excel ,is it
possible ? because this EXE file might be in different location on the hard
drive is it possible to write the codes the way that can look for this
specific file first (something like search) and then run it when it finds it
?Thanks,

Afshin.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code To find and run an EXE file out side of the Excel


To run it, just use the Shell command:

Shell("c:\winnt\notepad.exe")

To find it, you will have to have some clue where it might be. I don'
know of any built in file searching function in VBA. Someone may hav
posted one, so do a search for it (or a google search for VBA fil
search).

If it may be in a couple of places, you could use the DIR command t
see if it is the

s = Dir("c:\windows\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

s = Dir("c:\winnt\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

etc.



--
kkkni
-----------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754
View this thread: http://www.excelforum.com/showthread.php?threadid=26661

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Code To find and run an EXE file out side of the Excel

Thank you very much. for your help.


"kkknie" wrote in message
...

To run it, just use the Shell command:

Shell("c:\winnt\notepad.exe")

To find it, you will have to have some clue where it might be. I don't
know of any built in file searching function in VBA. Someone may have
posted one, so do a search for it (or a google search for VBA file
search).

If it may be in a couple of places, you could use the DIR command to
see if it is the

s = Dir("c:\windows\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

s = Dir("c:\winnt\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

etc.

K


--
kkknie
------------------------------------------------------------------------
kkknie's Profile:

http://www.excelforum.com/member.php...fo&userid=7543
View this thread: http://www.excelforum.com/showthread...hreadid=266619



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code To find and run an EXE file out side of the Excel

I don't
know of any built in file searching function in VBA.


Use the filesearch object.

sStr1 = "excel.exe"
set fs = Application.FileSearch
With fs
.NewSearch
.FileName = sStr1
.LookIn = "C:\"
.SearchSubFolders = True
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With
fs.Execute

sStr2 = ""
For r = 1 To fs.FoundFiles.Count
if instr(len(fs.foundfiles(r))-(len(sStr1)-1),fs.FoundFiles(r), _
sStr1,vbTextCompare) then
sStr2 = fs.FoundFiles(r)
fr = r
exist for
end if
Next r
if sStr2 < "" then
msgbox fs.FoundFiles(fr) & " was found"
End If

It only searches one path and its subdirectories, so if you can narrow it
down to which drive it should work, or you can loop over all drives.

--
Regards,
Tom Ogilvy


"kkknie" wrote in message
...

To run it, just use the Shell command:

Shell("c:\winnt\notepad.exe")

To find it, you will have to have some clue where it might be. I don't
know of any built in file searching function in VBA. Someone may have
posted one, so do a search for it (or a google search for VBA file
search).

If it may be in a couple of places, you could use the DIR command to
see if it is the

s = Dir("c:\windows\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

s = Dir("c:\winnt\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

etc.

K


--
kkknie
------------------------------------------------------------------------
kkknie's Profile:

http://www.excelforum.com/member.php...fo&userid=7543
View this thread: http://www.excelforum.com/showthread...hreadid=266619



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Code To find and run an EXE file out side of the Excel

Thank Tom,

I am not sure about this but I think using the "Dir" command in "DOS" mode
plus " /S " switch and finally process the results would help, don't you
think so? Thanks,

Regards,
Afshin.


"Tom Ogilvy" wrote in message
...
I don't
know of any built in file searching function in VBA.


Use the filesearch object.

sStr1 = "excel.exe"
set fs = Application.FileSearch
With fs
.NewSearch
.FileName = sStr1
.LookIn = "C:\"
.SearchSubFolders = True
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With
fs.Execute

sStr2 = ""
For r = 1 To fs.FoundFiles.Count
if instr(len(fs.foundfiles(r))-(len(sStr1)-1),fs.FoundFiles(r), _
sStr1,vbTextCompare) then
sStr2 = fs.FoundFiles(r)
fr = r
exist for
end if
Next r
if sStr2 < "" then
msgbox fs.FoundFiles(fr) & " was found"
End If

It only searches one path and its subdirectories, so if you can narrow it
down to which drive it should work, or you can loop over all drives.

--
Regards,
Tom Ogilvy


"kkknie" wrote in message
...

To run it, just use the Shell command:

Shell("c:\winnt\notepad.exe")

To find it, you will have to have some clue where it might be. I don't
know of any built in file searching function in VBA. Someone may have
posted one, so do a search for it (or a google search for VBA file
search).

If it may be in a couple of places, you could use the DIR command to
see if it is the

s = Dir("c:\windows\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

s = Dir("c:\winnt\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

etc.

K


--
kkknie
------------------------------------------------------------------------
kkknie's Profile:

http://www.excelforum.com/member.php...fo&userid=7543
View this thread:

http://www.excelforum.com/showthread...hreadid=266619







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code To find and run an EXE file out side of the Excel

I would be a workable approach.

--
Regards,
Tom Ogilvy

"A-Design" wrote in message
...
Thank Tom,

I am not sure about this but I think using the "Dir" command in "DOS"

mode
plus " /S " switch and finally process the results would help, don't you
think so? Thanks,

Regards,
Afshin.


"Tom Ogilvy" wrote in message
...
I don't
know of any built in file searching function in VBA.


Use the filesearch object.

sStr1 = "excel.exe"
set fs = Application.FileSearch
With fs
.NewSearch
.FileName = sStr1
.LookIn = "C:\"
.SearchSubFolders = True
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
End With
fs.Execute

sStr2 = ""
For r = 1 To fs.FoundFiles.Count
if instr(len(fs.foundfiles(r))-(len(sStr1)-1),fs.FoundFiles(r), _
sStr1,vbTextCompare) then
sStr2 = fs.FoundFiles(r)
fr = r
exist for
end if
Next r
if sStr2 < "" then
msgbox fs.FoundFiles(fr) & " was found"
End If

It only searches one path and its subdirectories, so if you can narrow

it
down to which drive it should work, or you can loop over all drives.

--
Regards,
Tom Ogilvy


"kkknie" wrote in message
...

To run it, just use the Shell command:

Shell("c:\winnt\notepad.exe")

To find it, you will have to have some clue where it might be. I

don't
know of any built in file searching function in VBA. Someone may have
posted one, so do a search for it (or a google search for VBA file
search).

If it may be in a couple of places, you could use the DIR command to
see if it is the

s = Dir("c:\windows\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

s = Dir("c:\winnt\notepad.exe")
if s < "" then Shell("c:\windows\notepad.exe")

etc.

K


--
kkknie


------------------------------------------------------------------------
kkknie's Profile:

http://www.excelforum.com/member.php...fo&userid=7543
View this thread:

http://www.excelforum.com/showthread...hreadid=266619







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
How do I turn on side by side workbook feature in Excel 2007? Halina Excel Discussion (Misc queries) 3 August 15th 08 03:36 PM
How do I open an Excel web file out side of the web browser view? Rwhite Excel Discussion (Misc queries) 1 October 26th 07 06:53 PM
excel should cut & paste lists side by side to save paper Richierich Excel Worksheet Functions 1 March 10th 06 12:42 AM
How to print 2 Excel pages side by side on 1 printed page? Kathy Install Excel Discussion (Misc queries) 1 September 29th 05 05:03 PM
Cant get my code work. Find file or create it Poseilus Excel Programming 1 October 12th 03 03:42 PM


All times are GMT +1. The time now is 02:24 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"