#1   Report Post  
tkaplan
 
Posts: n/a
Default flash drive


I have the following code in my workbook:

Dim wbpath AS String

With ThisWorkbook
wbpath = .Path
End With

ChDir wbpath
FileName = Brand & txtCenter.Value & " FY2006 Audit Form"
ActiveWorkbook.SaveAs FileName

This saves the workbook in the same location as it currently is but
under a new name. This works fine.

The problem i'm having:
I am distributing this workbook on a flash drive. when i open the file
from there and run the macro, it saves the new file to my documents,
not to the location of the original.

Is there something wrong with my code? or is there something with excel
that wont let you do a save as to a removable drive?
i need the file to save that no matter where the user runs it from,
they will always know that the new file will be in the same folder.

Thanks in advance.


--
tkaplan
------------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
View this thread: http://www.excelforum.com/showthread...hreadid=480234

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default flash drive

Changing the path might not be enough.

ChDrive wbpath
chdir wbpath

or just put it in the filename and avoid the changing of drives/paths:

filename = wbpath & "\" & Brand & txtCenter.value & " FY2006 Audit Form"

======
But a word of warning. I don't think I would ever save directly to that
removable drive. I'd save to the hard drive (or LAN) and then copy to the
removable drive.

I think that too many things can go wrong with removable media.

tkaplan wrote:

I have the following code in my workbook:

Dim wbpath AS String

With ThisWorkbook
wbpath = .Path
End With

ChDir wbpath
FileName = Brand & txtCenter.Value & " FY2006 Audit Form"
ActiveWorkbook.SaveAs FileName

This saves the workbook in the same location as it currently is but
under a new name. This works fine.

The problem i'm having:
I am distributing this workbook on a flash drive. when i open the file
from there and run the macro, it saves the new file to my documents,
not to the location of the original.

Is there something wrong with my code? or is there something with excel
that wont let you do a save as to a removable drive?
i need the file to save that no matter where the user runs it from,
they will always know that the new file will be in the same folder.

Thanks in advance.

--
tkaplan
------------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
View this thread: http://www.excelforum.com/showthread...hreadid=480234


--

Dave Peterson
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
USB Flash Drive JulianB Excel Discussion (Misc queries) 4 July 10th 06 12:54 AM
File in C drive is always trying to access Drive A Andre Croteau Excel Discussion (Misc queries) 3 August 9th 05 01:13 PM
How do I use flash drive in Excel.(selected drive is not in use) Douglas123toexcel Excel Discussion (Misc queries) 2 June 23rd 05 11:52 PM
Default Drive Question Mel Excel Discussion (Misc queries) 2 March 11th 05 04:34 PM
Linking an entire worksheet from a restricted drive? mkichar Excel Worksheet Functions 1 November 4th 04 07:29 PM


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

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"