Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba vista excel

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA, Vista, Excel2007

VBA, Vista, Excel2007

ResolvedVersion 2003

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

Thu 17 Dec 2009: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Wrapping Text in a Cell in an Excel 2010 Workbook

When you have a lot of text you want to put in a particular cell but you can't decrease the font size to fit because the text will then become ineligible, then manually wrap the text in a cell by simply pressing ALT+ENTER.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.