• Wayward custom document property

    Author
    Topic
    #353539

    Hi

    I have a macro that includes the following code:
    ActiveDocument.CustomDocumentProperties(“HoursMon1”) = Val(txtHoursMon1)

    txtHoursMon1 is a variable picked up from a form. It has a value of 6.5.

    HoursMon1 is a NUMERIC custom property, already defined.

    When the line is executed, HoursMon1 takes the value of 6 (rather than 6.5, as expected).

    Any ideas?
    Dale

    Viewing 0 reply threads
    Author
    Replies
    • #517448

      It sounds like your HoursMon1 is declared as an Integer. Can you define it as
      Dim HoursMon1 as Double

      • #517482

        I’m not sure what you mean, Andrew.

        txtHoursMon1 (the variable on the right) is defined in a form, and is therefore a string (I think).

        • #517484

          Can you define the custom property as a String? Does it positively have to be a numeric? If you define it as text then the full number goes in quite happily.

          The code is not simply truncating the number as 12.7 goes in as 13. It sure looks like a bug

          • #517496

            I told you not to tell me this is a bug!!!

            Ah well, I’ll redefine it as Text, as you suggest. Mr Gates sure has a lot to answer for.

            Thanks for your help
            Dale

            • #517500

              Hi,

              What I’ve found, in Word 2000 SR-1, is that if you initially define the custom value as number, but put in an integer, it thinks it’s an integer from then on. But if you give it an initial value wit a decimal point, it will hold a value with a decimal point later. You can even add a value of “0.” when you define it initially, and it will handle decimals OK later.

              To be safe, you could delete then re-add the custom value instead of just updating it.

            • #517838

              Thanks, Geoff

              I gave it a try in Word97, but it didn’t work. So I’ve ended up using Andrew’s suggestion of redefining the custom property as Text. This meant more work, but it’s worked.

              Thanks to you both
              Dale

    Viewing 0 reply threads
    Reply To: Wayward custom document property

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: