PrivateProfileString

C

Colleen M

I have been using this method to store user defaults for client templates. In
probably 8 years I've never had a problem with it. Now, I've had two testers
run into problems where the .ini file doesn't seem to be storing, or if it
does, it's not where I expect it to be. Since the client is in another city,
I can't just sit at their PCs and figure out what's going on, so wonder if
anyone here might have experienced any problems with this method. Word 2003.

System.PrivateProfileString _
("c:\" + vUser, "CHRTemplates", Key) = Value

sGetProfile = System.PrivateProfileString _
("c:\" + vUser, "CHRTemplates", Key)

vUser is Application.UserName
 
J

Jay Freedman

I have been using this method to store user defaults for client templates. In
probably 8 years I've never had a problem with it. Now, I've had two testers
run into problems where the .ini file doesn't seem to be storing, or if it
does, it's not where I expect it to be. Since the client is in another city,
I can't just sit at their PCs and figure out what's going on, so wonder if
anyone here might have experienced any problems with this method. Word 2003.

System.PrivateProfileString _
("c:\" + vUser, "CHRTemplates", Key) = Value

sGetProfile = System.PrivateProfileString _
("c:\" + vUser, "CHRTemplates", Key)

vUser is Application.UserName

Maybe Application.UserName is returning an empty string or something
that isn't valid in a filename.

More probably it's external to Word: Do the users have read/write
access to the root directory? Is there some antivirus or antispyware
application that's interfering?

Are there any messages, or anything in the Event Log (Application or
System)? Does a full-drive search turn up the file, or any file with
the expected contents, in an unexpected place?

Have you considered writing the value to the registry instead of an
external file? PrivateProfileString will do that if you pass an empty
string ("") as the first parameter.
 
C

Colleen M

Thanks, Jay. Turns out the answer is one you suggested: that the users in
question don't have read/write access to the root of c:

I think next time I have a project to do I'll explore using the registry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top