vba drive ID

EDUCATED MONKEY

Board Regular
Joined
Jul 17, 2011
Messages
218
the set up office 2007 xp pro ie8

I am looking for a VBA solution to the following problem:-<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
I have stored my spreadsheet on a portable Drive that attaches to the USB port, along with it are some jpegs that are loaded in to the sheet <o:p></o:p>
Now everything is fine if I stay working on the same PC if however, I plug the drive in to a different pc that has say a D drive then the next drive becomes E, and the drive letter referred to in the spreadsheet no long matches, the solution at this time is just to change the reference manually clearly this would be a problem for others that are involved with the data entry side of things have little or no knowledge of Drive letters etc, so I am looking for some VBA to detect the drive letter and change references as necessary
also could some one please tell me should i be marking these questions solved if so how<o:p></o:p>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

GTO

MrExcel MVP
Joined
Dec 9, 2008
Messages
6,154
If I am reading this right, you are saying that its the code in the workbook that has a hard reference to the root? If this is the case, just use the current path to the workbook. Something like:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Try()<br><SPAN style="color:#00007F">Dim</SPAN> Root <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> Path <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br><br>  Root = Left(ThisWorkbook.Path, InStr(1, ThisWorkbook.Path, "\"))<br>  Path = Root & "MyData\Whatever Folder\Etc\"<br>  <br>  MsgBox Path<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

Please note this is just if you are using a path like C:\Etc\ not //whatever that other ones called/
 

Watch MrExcel Video

Forum statistics

Threads
1,130,047
Messages
5,639,766
Members
417,109
Latest member
996

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top