Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Saving to USB Drive either D or E

Hi I would like to be able to have a workbook save to either D or E
when a button is pressed on a worksheet, we have panasonic toughbooks
I have the following code which worked and checked if a USB drive is
in D. Work has recently bought encrypted USB Drives where the drive
letter is now E, but I would still like the user to be able to save to
D on unencrpyted USB drives..

Sub AASAVETOSTICK()
' AASAVETOSTICK Macro save to d without rename
' Macro recorded 19/03/2007 by *
On Error GoTo AASAVETOSTICK_Error
Application.DisplayAlerts = False
ChDir "d:\"
ActiveWorkbook.SaveAs Filename:="d:\April.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=True
Application.DisplayAlerts = True
On Error GoTo 0
Exit Sub
AASAVETOSTICK_Error:
MsgBox ("Please put USB Key into USB slot")
End Sub


Sub saveit()
' save to d but rename workbook
response = MsgBox("Rename & Save to District Supervisors USB Key?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then End
On Error GoTo AASAVETOSTICK_Error
ActiveWorkbook.SaveAs Filename:="D:\" & Name & ".xls"
End If
On Error GoTo 0
Exit Sub
AASAVETOSTICK_Error:
MsgBox ("Please put USB Key into USB slot")
End Sub

Thanks in advance Stephen

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Saving to USB Drive either D or E

Hi Stephen,

Could you try something like:

If response = vbYes Then
ActiveWorkbook.SaveAs Filename:="D:\" & Name & ".xls"
ElseIf response = vbNo Then
ActiveWorkbook.SaveAs Filename:="E:\" & Name & ".xls"
Else
Exit Sub
End If


Is it not possible to use the Application.GetSaveAsFilename to let them
choose the location and filename in one go, and then just use the SaveAs with
the string that is returned?

Sean.

--
(please remember to click yes if replies you receive are helpful to you)


"pano" wrote:

Hi I would like to be able to have a workbook save to either D or E
when a button is pressed on a worksheet, we have panasonic toughbooks
I have the following code which worked and checked if a USB drive is
in D. Work has recently bought encrypted USB Drives where the drive
letter is now E, but I would still like the user to be able to save to
D on unencrpyted USB drives..

Sub AASAVETOSTICK()
' AASAVETOSTICK Macro save to d without rename
' Macro recorded 19/03/2007 by *
On Error GoTo AASAVETOSTICK_Error
Application.DisplayAlerts = False
ChDir "d:\"
ActiveWorkbook.SaveAs Filename:="d:\April.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=True
Application.DisplayAlerts = True
On Error GoTo 0
Exit Sub
AASAVETOSTICK_Error:
MsgBox ("Please put USB Key into USB slot")
End Sub


Sub saveit()
' save to d but rename workbook
response = MsgBox("Rename & Save to District Supervisors USB Key?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter a Filename", "Get Filename")
If Name = "" Then End
On Error GoTo AASAVETOSTICK_Error
ActiveWorkbook.SaveAs Filename:="D:\" & Name & ".xls"
End If
On Error GoTo 0
Exit Sub
AASAVETOSTICK_Error:
MsgBox ("Please put USB Key into USB slot")
End Sub

Thanks in advance Stephen


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
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
Problems Saving on a shared drive Anthony Excel Discussion (Misc queries) 0 March 20th 05 10:13 PM


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