Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I turn on side by side workbook feature in Excel 2007? | Excel Discussion (Misc queries) | |||
How do I open an Excel web file out side of the web browser view? | Excel Discussion (Misc queries) | |||
excel should cut & paste lists side by side to save paper | Excel Worksheet Functions | |||
How to print 2 Excel pages side by side on 1 printed page? | Excel Discussion (Misc queries) | |||
Cant get my code work. Find file or create it | Excel Programming |