PC Review


Reply
Thread Tools Rate Thread

check if drive exists - if not prompt to SAVE AS box

 
 
Paul
Guest
Posts: n/a
 
      17th Dec 2008
Hi All,
I would really appreciate some help on this as my VB skills are not
good, I can often work with code from this group,but I am stuck on
this.

the code below will save a copy of a worksheet to the H Drive with a
file name with sheet name (paddock), cell reference and date time .xls
My problem is to check if H drive exists, then if it does not exist,
to prompt to SAVE As for user input to select another file on C drive
with the given file name.

appreciate any help on this.

here is the code.

Sub SaveASPaddock()


'This macro will SAVE AS to H:\ folder, which must exist before macro
runs
ActiveSheet.Unprotect
Sheets("Paddock").Select
Range("A3").Select

Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
Range("A1").Select

Application.CutCopyMode = False
ActiveWorkbook.SaveAsApplication.GetSaveAsFilename "H:\" &
"PaddockFee_" & Range("D1").Value & "_" & Format(Now, "yyyymmddhhmm")
& ".xls"


ActiveWorkbook.Close SaveChanges:=False

Sheets("Paddock").Select
Range("A3").Select
ActiveSheet.Protect UserInterfaceOnly:=True
End Sub

Thanks in advance
Cheers Paul
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      18th Dec 2008

You can check for the existence of a drive using the FileSystemObject...
'--
Function DriveStatus(drv As String) As Boolean
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
DriveStatus = fso.DriveExists(drv)
Set fso = Nothing
End Function
'--

So...
If DriveStatus("H") = True Then
'save file
Else
'chose another drive
End If
--
Jim Cone
Portland, Oregon USA




"Paul"
wrote in message
Hi All,
I would really appreciate some help on this as my VB skills are not
good, I can often work with code from this group,but I am stuck on
this.

the code below will save a copy of a worksheet to the H Drive with a
file name with sheet name (paddock), cell reference and date time .xls
My problem is to check if H drive exists, then if it does not exist,
to prompt to SAVE As for user input to select another file on C drive
with the given file name.
appreciate any help on this.
here is the code.

Sub SaveASPaddock()
'This macro will SAVE AS to H:\ folder, which must exist before macro
runs
ActiveSheet.Unprotect
Sheets("Paddock").Select
Range("A3").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.SaveAsApplication.GetSaveAsFilename "H:\" &
"PaddockFee_" & Range("D1").Value & "_" & Format(Now, "yyyymmddhhmm")
& ".xls"
ActiveWorkbook.Close SaveChanges:=False
Sheets("Paddock").Select
Range("A3").Select
ActiveSheet.Protect UserInterfaceOnly:=True
End Sub

Thanks in advance
Cheers Paul
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      18th Dec 2008
thanks Jim
Appreciate the asisstance here.
Trying out this code now.
Cheers Paul

On Dec 18, 11:39*am, "Jim Cone" <james.cone...@comcast.netxxx> wrote:
> You can check for the existence of a drive using the FileSystemObject...
> '--
> Function DriveStatus(drv As String) As Boolean
> * *Dim fso As Object
> * *Set fso = CreateObject("Scripting.FileSystemObject")
> * *DriveStatus = fso.DriveExists(drv)
> * *Set fso = Nothing
> End Function
> '--
>
> So...
> If DriveStatus("H") = True Then
> * *'save file
> Else
> * 'chose another drive
> End If
> --
> Jim Cone
> Portland, Oregon *USA
>
> "Paul"
> wrote in message
> Hi All,
> I would really appreciate some help on this as my VB skills are not
> good, I can often work with code from this group,but I am stuck on
> this.
>
> the code below will save a copy of a worksheet to the H Drive with a
> file name with sheet name (paddock), cell reference and date time .xls
> My problem is to check if H drive exists, then if it does not exist,
> to prompt to SAVE As for user input to select another file on C drive
> with the given file name.
> appreciate any help on this.
> here is the code.
>
> Sub SaveASPaddock()
> 'This macro will SAVE AS to H:\ *folder, which must exist before macro
> runs
> * * ActiveSheet.Unprotect
> * * Sheets("Paddock").Select
> * * Range("A3").Select
> * * Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
> * * Selection.Copy
> * * Workbooks.Add
> * * Range("A1").Select
> * * Selection.PasteSpecial Paste:=xlPasteValues
> * * Selection.PasteSpecial Paste:=xlPasteFormats
> * * Range("A1").Select
> * * Application.CutCopyMode = False
> * * ActiveWorkbook.SaveAsApplication.GetSaveAsFilename "H:\" &
> "PaddockFee_" & Range("D1").Value & "_" & Format(Now, "yyyymmddhhmm")
> & ".xls"
> * * ActiveWorkbook.Close SaveChanges:=False
> * * Sheets("Paddock").Select
> * * Range("A3").Select
> * * ActiveSheet.Protect UserInterfaceOnly:=True
> End Sub
>
> Thanks in advance
> Cheers Paul


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
prompt to save on exit - disable prompt on save button Mel Microsoft ASP .NET 10 13th Feb 2009 05:32 AM
Check if a directory exists in a network drive? Joris De Groote Microsoft ASP .NET 2 11th Apr 2006 05:39 PM
save prompt for user exit, but no save prompt for batch import? =?Utf-8?B?bHBq?= Microsoft Excel Misc 1 25th Feb 2006 02:08 AM
prompt to save message to local drive/directory =?Utf-8?B?U3RhdE1hbg==?= Microsoft Outlook Discussion 3 21st Mar 2005 04:17 PM
Save file to Network Drive and prompt for name turtle Microsoft Excel Programming 3 15th Jan 2004 02:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:28 AM.