Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Dynamic drive selection to update link

I have the below code live.. but can I have a code that search in drive F, G,
H if this path does not exist?

That is it should search in
"F:\Primary\Master-May.xls", _
"G:\Primary\Master-May.xls", _
"H:\Primary\Master-May.xls", _

Sub ref()

ActiveWorkbook.UpdateLink Name:= _
"E:\Primary\Master-May.xls", _
Type:=xlExcelLinks

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Dynamic drive selection to update link

Option explicit
Sub ref()
Dim myList as variant
dim iCtr as long
dim TestStr as string
dim FoundIt as boolean

mylist = array("F:\Primary\Master-May.xls", _
"G:\Primary\Master-May.xls", _
"H:\Primary\Master-May.xls")

foundit=false
for ictr = lbound(mylist) to ubound(mylist)
teststr = ""
on error resume next
teststr = dir(mylist(ictr))
on error goto 0

if teststr = "" then
'not found, keep looking
else
foundit = true
ActiveWorkbook.UpdateLink Name:=mylist(ictr), Type:=xlExcelLinks
exit for
end if
next ictr

if foundit = false then
msgbox "not found in any of those places!"
else
msgbox "Updated!
end if

End Sub

Kashyap wrote:

I have the below code live.. but can I have a code that search in drive F, G,
H if this path does not exist?

That is it should search in
"F:\Primary\Master-May.xls", _
"G:\Primary\Master-May.xls", _
"H:\Primary\Master-May.xls", _

Sub ref()

ActiveWorkbook.UpdateLink Name:= _
"E:\Primary\Master-May.xls", _
Type:=xlExcelLinks

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Dynamic drive selection to update link

If you are using a network I would use the drive name rather than the letter

"\\networkname\Master-May.xls"

You can find the network name in windows explorer by going to menu

tools - disconnect Netwrok Drive

MyDrives = Array( _
"F:\Primary\Master-May.xls", _
"G:\Primary\Master-May.xls", _
"H:\Primary\Master-May.xls")

Set fs = CreateObject("Scripting.FileSystemObject")
MyDrive = ""
for each Drv in MyDrives
if fs.DriveExists(Drv) = true then
MyDrive = Drv
exit for
end if
end if

if Drv = "" then
msgbox("Drive not found")
end if
"Kashyap" wrote:

I have the below code live.. but can I have a code that search in drive F, G,
H if this path does not exist?

That is it should search in
"F:\Primary\Master-May.xls", _
"G:\Primary\Master-May.xls", _
"H:\Primary\Master-May.xls", _

Sub ref()

ActiveWorkbook.UpdateLink Name:= _
"E:\Primary\Master-May.xls", _
Type:=xlExcelLinks

End Sub

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
update all hyperlinks to another drive Filips Benoit[_2_] Excel Programming 1 November 14th 07 10:26 AM
Import from MS Access - Lose the drive letter..link only to drive Cyhill Excel Programming 6 September 17th 07 06:42 PM
Link to Network Drive Keith Excel Discussion (Misc queries) 3 March 15th 07 06:23 PM
Link to Network Drive Keith New Users to Excel 3 March 15th 07 06:23 PM
Link workbooks-C drive to network drive Earl Excel Worksheet Functions 0 April 19th 05 05:50 PM


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