Save As

Paddy1979

Well-known Member
Joined
Sep 23, 2005
Messages
608
Hello everyone.

Is its possible it check whether a users C:\ is in read only mode i.e you cannot save a file there ?

As my macro is falling over as it saves the file as C:\MPimport.xls but if this is prevented i need to save as H:\MPimport.xls

Many Thanks
Patrick
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,939
Maybe you can just use error handling. This is a very basic example, but maybe you can expand on it:

Code:
Sub SaveToC
On Error Goto Handler
'Code to save in C:\
 
Exit Sub
Handler:
'Code to save in H:\
End Sub
Hope that helps.
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi Patrick

Here's a function that should work to test this:

Code:
Function DriveWriteable(DriveLetter As String) As Boolean
Dim i As Integer
i = FreeFile
On Error Resume Next
Open DriveLetter & ":\TestAccess.txt" For Binary Access Write As #i
If Err = 0 Then
    DriveWriteable = True
    Close #i
End If
End Function

Use in code like:

Code:
If DriveWriteable("C") Then
    'save to C drive
Else
  'save to other drive
End If
 

Paddy1979

Well-known Member
Joined
Sep 23, 2005
Messages
608
Thanks Richard , (again ) , thats just what i was after.

Thanks also schielrn
 

Watch MrExcel Video

Forum statistics

Threads
1,130,048
Messages
5,639,769
Members
417,111
Latest member
buyukbang

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