Roger has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course
VBA, Vista, Excel2007
I attended Anthony's VBA course yesterday.
He provided some code, similar to that below, to create a new spreadsheet at the end of a macro. His code wrote to c:\ and I noted that this is difficult in Vista. Anthony asked me to send details.
I wrote the code below to test this. I used a spreadsheet with just a few numbers in it and tried to create testoutput.xls.
Vista will not write to C:\testoutput.xls, but will write to
c:\TestDir\testoutput.xls. It works with both under XP
Sub saveme()
Dim mynewfilename As String
Dim strName As String
strName = "InputSheet"
mynewfilename = "c:\" & "testoutput.xls"
'mynewfilename = "c:\TestDir\" & "testoutput.xls"
Sheets(strName).Select
Sheets(strName).Copy
ActiveWorkbook.SaveAs Filename:=mynewfilename
ActiveWorkbook.Close
End Sub
In fact, a simpler test is to simply try a dos command. If I go to any directory in a Vista Ultimate machine and type something like COPY TEST.DAT C:\ ,it will return the message 'access denied' so its no surprise that I cannot go there via VBA.
Any comments gratefully received.
Roger
RE: VBA, Vista, Excel2007
Hi Roger, thanks for your query. I've done some digging and this seems to be an acknowledged problem with Vista Ultimate. Have a look at this link:
http://www.vistax64.com/general-discussion/232408-access-c-drive-denied-vista.html
...which discusses Service Pack 2, and also this link:
http://www.annoyances.org/exec/forum/winvista/1193690928
...particularly the first reply from Steve which suggests
"Try turning off UAC http://www.petri.co.il/disable_uac_in_windows_vista.htm" ;
I have no copy of Vista Ultimate myself to test and find a workaround for your problem myself but see whether these links yield a solution. Let me know how you get on.
All the best,
Anthony