LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Saving to a USB drive

Hi,

I've written a macro and have gotten to the point where I'd like the macro
to save the file. I'm trying to make the macro as easy to use as possible.
To that end, I'd like the macro to save the generated file to a USB stick,
which has a drive letter that is variable. It is either E: or F:, depending
on which stick is used. The user can either save to the desktop or to the
USB key. What I'd like to happen is if the drive is not E then try F. If it
is neither, then a USB stick is not inserted and a message should pop up to
say restart the macro after inserting the stick and the macro should end.
Currently, only an error pops up to debug if no stick is inserted (which I do
not want them to do).

This is what I have so far:

' Method to save file either to USB stick or to Desktop
Dim fPath As String
fPath = "C:\Documents and Settings\" & Environ("username") & "\Desktop\"

file = ActiveWorkbook.Name
Windows("HELO Macros.xls").Activate

If Range("D3") = "To Stick" Then
Windows(file).Activate
ActiveWorkbook.SaveAs Filename:="E:\Runlogs\" & Name & "-" &
ilngFileNumber, FileFormat:=xlWorkbookNormal

ElseIf Range("D3") = "To Desktop" Then
Windows(file).Activate
ActiveWorkbook.SaveAs Filename:=fPath & Name & "-" & ilngFileNumber,
FileFormat:=xlWorkbookNormal
End If


Thank you!
Matt
 
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
Saving to USB Drive either D or E pano[_3_] Excel Programming 1 October 26th 07 11:45 AM
saving drive d maddo54 Excel Discussion (Misc queries) 0 March 13th 06 03:17 PM
Problem saving to network drive Peter Rooney Excel Programming 11 November 30th 05 01:10 PM
EXCEL saving to A: drive LindaD Excel Discussion (Misc queries) 2 October 10th 05 11:53 PM


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