Runtime Error 75 Help

Talat

New Member
Joined
Sep 17, 2004
Messages
33
Hi,

I am working on a piece of code which checks to see if a particular directory name exists and if not create it, later saving an excel file into it. It works well first time, but when on subsequent runs the code tries to open and save another file in this same directory it returns error 75

I checked the creataed directory access rights and it shows that directory is Read Only. How do I set the ditrectroy access writes at the time of creation?

It seems that it does not even allow me to change it manually from the properties dialogue? Here is the code:

Code:
Sub ArchiveFile()


Dim strDN As String
Dim strFN As String

ChDir "G:\PUBS\PP-MS\INVOICES"

strDN = Range("E5")

MsgBox strDN

'If Len(Dir("c:\Instructions.doc")) = 0 Then
If Dir("G:\PUBS\PP-MS\INVOICES\" & strDN) = "" Then


MkDir ("G:\PUBS\PP-MS\INVOICES\" & strDN)
    Else
        'do nothing as the directory already exists
        'MsgBox "C:\Text Files\ directory already exists"
    End If

strFN = Range("K2") & ".xls"

MsgBox strFN

ChDir "G:\PUBS\PP-MS\INVOICES\" & strDN

ActiveWorkbook.SaveAs Filename:=strFN, _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False


End Sub

Will be grateful for any help on this.

Thanks,

Talât :-)

_________________________
I have added cool emoticons to this message.
To see them go to http://x.exps.me?a8c82571f6e62857d81620e870f3f5cb

_________________________
I have added cool emoticons to this message.
To see them go to http://x.exps.me?a8c82571f6e62857d81620e870f3f5cb
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi,
Please try below code and let me know if it works.

Code:
Sub ArchiveFile()
 
Dim strDN As String
Dim strFN As String
Dim x As String
 
On Error Resume Next
 
ChDir "G:\PUBS\PP-MS\INVOICES"
 
strDN = Range("E5")
MsgBox strDN
 
PathName = "G:\PUBS\PP-MS\INVOICES\" & strDN
 
x = GetAttr(PathName) And 0
If Err <> 0 Then
 
'*** code to create the directory***
    MkDir PathName
 
    strFN = Range("K2") & ".xls"
 
    MsgBox strFN
 
Else
        'do nothing as the directory already exists
        MsgBox "directory already exists"
 
End If
 
ChDir PathName
 
ActiveWorkbook.SaveAs Filename:=strFN, _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
 
End Sub
 
Upvote 0
Thanks Ogo.

I will check and come back to you. I am off for couple of days, so probably on Wednesday.

Cheers.

Talât
 
Upvote 0
Thanks Ogo. I have tried this now and its working perfectly well now.
I am very grateful for your help in this. Much appreciated.

Best wishes.

Talât :-)
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,922
Latest member
nstaab07

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
Back
Top