vba vista excel

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

VBA, Vista, Excel2007

resolvedResolved · Low Priority · Version 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:

Generating Random Numbers

To generate a random number in Excel use the = RAND() function.

The value returned will always be between 0 and 1. To convert this to some other random value, you will need to multiply the result by the highest number you want to consider. For example, if you wanted a random number between 1 and 25, you could use the following code line:
= INT(25 * RAND()+ 1)

Since RAND() will always returns a value between 0 and 1 (but never 1 itself), multiplying what it returns by 25 and then using the Integer function INT on that result will return a whole number between 0 and 24.

Finally, 1 is added to this result, so that x will be equal to a number between 1 and 25, inclusive

View all Excel hints and tips


Server loaded in 0.07 secs.