Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting a Variable (Word 2003 SP2)

    I am trying to specify a pathname as follows to set a new variable called Order:

    ChangeDir = ChangeDir & "Settings.txt"
    Order = System.PrivateProfileString(" & ChangeDir & ", "MacroSettings", "Order")

    When I break the code and hover the mouse over the variable ChangeDir, it reads literally, quotes included in the pop-up: "C:NickSettings.txt"

    However the next line won't process. I mean, as I continue to step through the code, the Order variable reads nothing.

    Is there something wrong with the punctuation or cannot this be done?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Inserting a Variable (Word 2003 SP2)

    By using the quotes the way you do in the second line, the first argument of PrivateProfileString is the literal text
    <pre><span style="background-color: #FFFF00; color: #000000; font-weight: bold"> & ChangeDir & </span hi>
    </pre>

    Try this instead:

    Order = System.PrivateProfileString(ChangeDir, "MacroSettings", "Order")

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting a Variable (Word 2003 SP2)

    I suspect that the command you're after is:

    Order = System.PrivateProfileString(ChangeDir, "MacroSettings", "Order")

    This would extract the "Order" key value from the "MacroSettings" section of the file "C:NickSettings.txt" and assign it to the local variable Order.

    Alan

    Only lost by 4 minutes! Getting better.

  4. #4
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting a Variable (Word 2003 SP2)

    Thank you so much. You were both 100% accurate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •