Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
default file location in a file Philippe Excel Programming 2 February 12th 07 08:16 PM
How can I force the file to over write the existing file Ed Excel Programming 1 August 21st 06 11:09 PM
How can I force the file to over write the existing file Ed[_29_] Excel Programming 0 August 16th 06 09:40 PM
How to write a micro to download file at a URL save the file at the local PC www.microsoft.com Excel Programming 2 March 9th 06 02:21 AM
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM


All times are GMT +1. The time now is 07:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"