View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default 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.