VBA XL 2010: Path / File access error ??

monirg

Well-known Member
Joined
Jan 11, 2005
Messages
629
Hello;

1) Here’s another example of XL 2003 w/b code not working properly in XL 2010, but it appears specific enough in this case!
The w/b Open() event code had been copied a while back from an XL ref, and the w/b works perfectly in XL 2003.
(I’ve just opened and run the w/b in XL 2003 with no problem!)

2) When the XL 2003 w/b is opened in XL 2010, I get the error:
Run-time error ‘75’:
Path / File access error
and the Open statement in the following code is highlighted.

3) Top section of the code:
Code:
Private Sub Workbook_Open()
Dim StartTime#, CurrentTime#
 
  Const TrialPeriod# = 30 
 
'set own obscure path and file-name
  Const ObscurePath$ = "C:\"
  Const ObscureFile$ = "TestFileLog.Log"
 
If Dir(ObscurePath & ObscureFile) = Empty Then
   StartTime = Format(Now, "#0.#########0")
   [B][SIZE=3]Open ObscurePath & ObscureFile For Output As #1[/SIZE][/B]
Your help would be greatly appreciated.

Regards.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Just a guess but if your system has changed (which is why you have 2010 now) the file permissions for access to the root drive may have changed. It's not uncommon for C: to be reserved to administrative users. Maybe test with a log file in another location?
 
Upvote 0
Hi xenou;
Thank you for your reply and good to hear from you!

1) I forgot to mention in the OP that it’s a local computer (no Network), runing Office 2010 (only), and I’m the only User/Computer Administrator.
Under the User Accounts on the (new) 2010 m/c, it displays only one a/c, which is the correct a/c:
Monir
Administrator
Password protected
Exactly as I have it on the XL 2003 computer!

2) So basically, everything should be accessible to me once I log on. Furthermore, I’ve installed, changed, created new folders & files, etc., in the the root directory C:\ of the 2010 m/c with no problems. Mind you, manually and not via XL 2010 VBA code as described in the OP.

Regards.
 
Upvote 0
Please try the suggestion and then we can continue if it doesn't work.
ξ
 
Upvote 0
Hi xenou;
Maybe test with a log file in another location?
I have just had the opportunity to try your suggestion.
It works fine. Thank you!

Any location on the new laptop except the root directory C:\ appears to be working fine.
So for now, I’ve opted for the w/b folder as the destination of the log file, even though my preference remains C:\.

Regards.
 
Upvote 0
Okay. I can't really explain why you can create files on C: otherwise, but not in code. It must be a security protocol related to protection against malicious scripts - I've been in a few situations where I couldn't write to the C: drive so I just avoid it anymore.

ξ
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,957
Members
448,535
Latest member
alrossman

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