ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating Subdirectory in "Default User" App Data (https://www.excelbanter.com/excel-programming/369174-creating-subdirectory-default-user-app-data.html)

pagates

Creating Subdirectory in "Default User" App Data
 
Hello All,

We have an Excel Add-In that creates an INI file in a subfolder under the
Application Data section of the current user ("C:\Documents and
Settings\CURRENTUSER\Application Data\Our Company\Our
Product\OurOptions.INI"). If the Add-In is used in a background process, it
attempts to create the folders under the Default User (usually "C:\Documents
and Settings\Default User\Application Data"). The problem is, it doesn't
have permission to do so, and hangs the process. However, if the "Our
Company" folder exists, it does have permission and creates the "Our Product"
folder with no problem.

Does anybody know of a way to create the "Our Company" folder automatically
under the Default User's Application Data path?

Thanks,
PAGates

Ron de Bruin

Creating Subdirectory in "Default User" App Data
 
This is working for me at home

MkDir "C:\Documents and Settings\" & Environ("Username") & "\Application Data\Our Company"


--
Regards Ron de Bruin
http://www.rondebruin.nl



"pagates" wrote in message ...
Hello All,

We have an Excel Add-In that creates an INI file in a subfolder under the
Application Data section of the current user ("C:\Documents and
Settings\CURRENTUSER\Application Data\Our Company\Our
Product\OurOptions.INI"). If the Add-In is used in a background process, it
attempts to create the folders under the Default User (usually "C:\Documents
and Settings\Default User\Application Data"). The problem is, it doesn't
have permission to do so, and hangs the process. However, if the "Our
Company" folder exists, it does have permission and creates the "Our Product"
folder with no problem.

Does anybody know of a way to create the "Our Company" folder automatically
under the Default User's Application Data path?

Thanks,
PAGates




Michel Pierron

Creating Subdirectory in "Default User" App Data
 
Hi pagates,
MkDir Environ(2) & "\Our Company"

MP

"pagates" a écrit dans le message de
news: ...
Hello All,

We have an Excel Add-In that creates an INI file in a subfolder under the
Application Data section of the current user ("C:\Documents and
Settings\CURRENTUSER\Application Data\Our Company\Our
Product\OurOptions.INI"). If the Add-In is used in a background process,
it
attempts to create the folders under the Default User (usually
"C:\Documents
and Settings\Default User\Application Data"). The problem is, it doesn't
have permission to do so, and hangs the process. However, if the "Our
Company" folder exists, it does have permission and creates the "Our
Product"
folder with no problem.

Does anybody know of a way to create the "Our Company" folder
automatically
under the Default User's Application Data path?

Thanks,
PAGates




NickHK

Creating Subdirectory in "Default User" App Data
 
As I was reminded the other, you should not use the numerals for the Environ
variables as the can return different values between computers.
Environ("APPDATA") will always be the same.

NickHK

"Michel Pierron" wrote in message
...
Hi pagates,
MkDir Environ(2) & "\Our Company"

MP

"pagates" a écrit dans le message de
news: ...
Hello All,

We have an Excel Add-In that creates an INI file in a subfolder under

the
Application Data section of the current user ("C:\Documents and
Settings\CURRENTUSER\Application Data\Our Company\Our
Product\OurOptions.INI"). If the Add-In is used in a background

process,
it
attempts to create the folders under the Default User (usually
"C:\Documents
and Settings\Default User\Application Data"). The problem is, it

doesn't
have permission to do so, and hangs the process. However, if the "Our
Company" folder exists, it does have permission and creates the "Our
Product"
folder with no problem.

Does anybody know of a way to create the "Our Company" folder
automatically
under the Default User's Application Data path?

Thanks,
PAGates






Michel Pierron

Creating Subdirectory in "Default User" App Data
 
Hi NickHK,
Yes, you are right, but sometimes, I am a little lazy.
:-) MP


"NickHK" a écrit dans le message de news:
...
As I was reminded the other, you should not use the numerals for the
Environ
variables as the can return different values between computers.
Environ("APPDATA") will always be the same.

NickHK

"Michel Pierron" wrote in message
...
Hi pagates,
MkDir Environ(2) & "\Our Company"

MP

"pagates" a écrit dans le message de
news:
...
Hello All,

We have an Excel Add-In that creates an INI file in a subfolder under

the
Application Data section of the current user ("C:\Documents and
Settings\CURRENTUSER\Application Data\Our Company\Our
Product\OurOptions.INI"). If the Add-In is used in a background

process,
it
attempts to create the folders under the Default User (usually
"C:\Documents
and Settings\Default User\Application Data"). The problem is, it

doesn't
have permission to do so, and hangs the process. However, if the "Our
Company" folder exists, it does have permission and creates the "Our
Product"
folder with no problem.

Does anybody know of a way to create the "Our Company" folder
automatically
under the Default User's Application Data path?

Thanks,
PAGates








pagates

Creating Subdirectory in "Default User" App Data
 
Hi All,

I am actually using Environ's big brother: the Win32 function
SHGetFolderPath. I imagine that Environ uses that somehow in the background.

This works fine for "real" users, but not when Excel runs in automation.

When I change the code to use Environ("APPDATA"), it no longer hangs, but it
doesn't create the correct path, either. It leaves off the entire path
before "\Our Company".

It appears that I have been able to get around these limitations using error
handling.

Thanks for your help,
PAGates

"Michel Pierron" wrote:

Hi NickHK,
Yes, you are right, but sometimes, I am a little lazy.
:-) MP


"NickHK" a écrit dans le message de news:
...
As I was reminded the other, you should not use the numerals for the
Environ
variables as the can return different values between computers.
Environ("APPDATA") will always be the same.

NickHK

"Michel Pierron" wrote in message
...
Hi pagates,
MkDir Environ(2) & "\Our Company"

MP

"pagates" a écrit dans le message de
news:
...
Hello All,

We have an Excel Add-In that creates an INI file in a subfolder under

the
Application Data section of the current user ("C:\Documents and
Settings\CURRENTUSER\Application Data\Our Company\Our
Product\OurOptions.INI"). If the Add-In is used in a background

process,
it
attempts to create the folders under the Default User (usually
"C:\Documents
and Settings\Default User\Application Data"). The problem is, it

doesn't
have permission to do so, and hangs the process. However, if the "Our
Company" folder exists, it does have permission and creates the "Our
Product"
folder with no problem.

Does anybody know of a way to create the "Our Company" folder
automatically
under the Default User's Application Data path?

Thanks,
PAGates









All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com