ProfileString returns error message.

J

Jan Meijer

Using the sample code from HELP in the macro:

Sub test()
MsgBox System.ProfileString("Options", "STARTUP-PATH")
End Sub

results in an error message 5843
'one of values passed is out of range'

What could be the reason behind this failure?
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jan,

I usually use System.PrivateProfileString as in the article at:
http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

While

MsgBox System.ProfileString("Options", "PROGRAMDIR")

works for me,

MsgBox System.ProfileString("Options", "STARTUP-PATH")

does not, but this may be because there is no key with that name under the
Options section in my Registry (Office 2003)

On the other hand, there is a key for DOC-PATH, but using

MsgBox System.ProfileString("Options", "DOC-PATH")

returns the same error message.
--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
J

Jan Meijer

Hi Doug,

As you did, I also had tried the PROGRAMDIR option with no
problems. Using the PPrivateProfileString is for me no
option, since I am looking for the START-UP path, which of
course in various releases can be different, hence it is
no option to put it in a txt- or ini like file.
My Registry has the entry STARTUP-PATH in place, but still
I receive the error message, just as you did with the DOC-
PATH.
In my opinion, this needs a more closer look by Microsoft,
which may result in 'install Office 2003'. Unfortunately
time schedule for doing so is bad.
Jan
 
T

Thomas Winter

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
Hi Jan,

I usually use System.PrivateProfileString as in the article at:
http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

While

MsgBox System.ProfileString("Options", "PROGRAMDIR")

works for me,

MsgBox System.ProfileString("Options", "STARTUP-PATH")

does not, but this may be because there is no key with that name under the
Options section in my Registry (Office 2003)

On the other hand, there is a key for DOC-PATH, but using

MsgBox System.ProfileString("Options", "DOC-PATH")

returns the same error message.
--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP

I recently read a Microsoft Knowledge base article that stated something
like with certain newer versions of Word, the STARTUP-PATH entry in the
registry is only created if the startup path is change by the user from its
default location.

Here's the article I believe:

WD2000: How to Find the Word Startup-Path by Using an External Solution:
http://support.microsoft.com/default.aspx?scid=kb;en-us;210860&Product=wrd

It says: "...Word 2000 (and Office 2000) will not write out the Startup-Path
key to the registry when using the new Roaming User feature and/or User
Profiles in Windows, unless the path is specifically changed by the user."

The article talks about how to find the Startup path from outside of Word.

Here's another article that might be helpful:

WD2000: How to Automatically Load or Distribute a VBA Project:
http://support.microsoft.com/default.aspx?scid=kb;en-us;292037&Product=wrd

But why don't you just use the Application.StartupPath property instead of
looking in the registry?

-Tom
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jan,

MsgBox Options.DefaultFilePath(wdStartupPath)

Will give the start up path. Also see the response to your post from Thomas
Winter.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
G

Guest

Great Guys,
Again is proven, although having several years experience
in VBA, one is never too old to learn more...
Both Tom's suggestion Application.StartupPath and Doug's
suggestion using FilePath(wdStartupPath) lead to the
correct answer (at least in Word 10)
BTW I DID specify a new location for the startup path and
it is correct in the registry, but still the ProfileString
does produce the error....
Anyway now I can use two alternatives as I like.
 

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