Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to write a file to a location.
I've created a procedure that will write the configuration of one of my
controls to an xml file. I've specified that it'll write the file to the root of the boot partition, but I'm finding that not everyone or not all users have permissions to write to that location. I need to change it so that it writes to a location where I know that my users will have permissions, like the desktop. Is there some variable that I can put in the path to specify the desktop of the current user? I know this isn't exactly an Excel related question even though my project is an Excel file. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to write a file to a location.
Hi
See he http://www.vbaexpress.com/kb/getarticle.php?kb_id=216 -- Wigi http://www.wimgielis.be = Excel/VBA, soccer and music "Jonathan Brown" wrote: I've created a procedure that will write the configuration of one of my controls to an xml file. I've specified that it'll write the file to the root of the boot partition, but I'm finding that not everyone or not all users have permissions to write to that location. I need to change it so that it writes to a location where I know that my users will have permissions, like the desktop. Is there some variable that I can put in the path to specify the desktop of the current user? I know this isn't exactly an Excel related question even though my project is an Excel file. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to write a file to a location.
The path for my desktop is
C:\Documents and Settings\barbara.reinhardt\Desktop What you'll need to do is figure out the user name and that can be done using the code here http://www.exceltip.com/st/Function_...Excel/452.html -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "Jonathan Brown" wrote: I've created a procedure that will write the configuration of one of my controls to an xml file. I've specified that it'll write the file to the root of the boot partition, but I'm finding that not everyone or not all users have permissions to write to that location. I need to change it so that it writes to a location where I know that my users will have permissions, like the desktop. Is there some variable that I can put in the path to specify the desktop of the current user? I know this isn't exactly an Excel related question even though my project is an Excel file. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to write a file to a location.
The user will always have access to the directories under the
%UserProfile% folder. You can get the location of that folder from the Environ function. E.g., Environ("UserProfile"). You can use code like the following: Sub AAA() Dim FName As String Dim FNum As Integer FName = Environ("UserProfile") & "\FileName.xml" On Error Resume Next Kill FName On Error GoTo 0 FNum = FreeFile Open FName For Output Access Write As #FNum Print #FNum, "<RootElement" ' write out your XML Print #FNum, "</RootElement" Close #FNum End Sub This type of IO is fine for simple XML, but if you are working with complicated XML, you might find it usefui to use the Microsoft XML, v6.0 library, typically located at C:\Windows\System32\msxml6.dll Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 31 Oct 2008 13:26:01 -0700, Jonathan Brown wrote: I've created a procedure that will write the configuration of one of my controls to an xml file. I've specified that it'll write the file to the root of the boot partition, but I'm finding that not everyone or not all users have permissions to write to that location. I need to change it so that it writes to a location where I know that my users will have permissions, like the desktop. Is there some variable that I can put in the path to specify the desktop of the current user? I know this isn't exactly an Excel related question even though my project is an Excel file. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to write a file to a location.
very cool! Thank you everyone.
"Chip Pearson" wrote: The user will always have access to the directories under the %UserProfile% folder. You can get the location of that folder from the Environ function. E.g., Environ("UserProfile"). You can use code like the following: Sub AAA() Dim FName As String Dim FNum As Integer FName = Environ("UserProfile") & "\FileName.xml" On Error Resume Next Kill FName On Error GoTo 0 FNum = FreeFile Open FName For Output Access Write As #FNum Print #FNum, "<RootElement" ' write out your XML Print #FNum, "</RootElement" Close #FNum End Sub This type of IO is fine for simple XML, but if you are working with complicated XML, you might find it usefui to use the Microsoft XML, v6.0 library, typically located at C:\Windows\System32\msxml6.dll Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 31 Oct 2008 13:26:01 -0700, Jonathan Brown wrote: I've created a procedure that will write the configuration of one of my controls to an xml file. I've specified that it'll write the file to the root of the boot partition, but I'm finding that not everyone or not all users have permissions to write to that location. I need to change it so that it writes to a location where I know that my users will have permissions, like the desktop. Is there some variable that I can put in the path to specify the desktop of the current user? I know this isn't exactly an Excel related question even though my project is an Excel file. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
default file location in a file | Excel Programming | |||
How can I force the file to over write the existing file | Excel Programming | |||
How can I force the file to over write the existing file | Excel Programming | |||
How to write a micro to download file at a URL save the file at the local PC | Excel Programming | |||
Open CSV file, format data and write output to a text file. | Excel Programming |