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.
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,675
Office Version
2013
Platform
Windows
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?
 

monirg

Well-known Member
Joined
Jan 11, 2005
Messages
629
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.
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,675
Office Version
2013
Platform
Windows
Please try the suggestion and then we can continue if it doesn't work.
ξ
 

monirg

Well-known Member
Joined
Jan 11, 2005
Messages
629
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.
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,675
Office Version
2013
Platform
Windows
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.

ξ
 

Watch MrExcel Video

Forum statistics

Threads
1,102,541
Messages
5,487,462
Members
407,601
Latest member
soccer4ward

This Week's Hot Topics

Top