Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro behaves differently on different computers (

    I wrote a Word macro that's working differently on two different computers. Both have Word 2003, SP2. On my computer, it works great; on my client's computer some of the code is not working right.

    Here are specifics: I originally wrote this macro six years ago in Word 2000. It's a lengthy macro, and essentially it manipulates text in the document on the screen to create a second document. I have full control over the footers in the document that is created because the macro starts with a form created by me. Recently, a problem was discovered when using the macro in Word 2003 in a part of the macro that edits the footer in the second Section. The symptom was that the second Section footer contained none of the text that the macro is supposed to insert.

    When troubleshooting, I discovered that when it came to inserting the text, the insertion point appeared to be in Nowhere Land--I couldn't find it. The code that inserts text with Selection.text was simply being ignored by the macro, presumably because the insertion point was who-knows-where. When testing, if I pressed the right arrow a couple of times with the macro halted at the point where the insertion point disappears, the insertion point would reappear at the start of the footer. I rewrote a couple of lines of code and now it works fine in Word 2003 at my computer. However, when I sent it to my client, it is still not working. (She deleted the old template and restarted her computer before trying it.) The template is saved in the User Templates folder.

    I can't figure out what would make the macro work differently at her computer with the same version of Word. We are testing the macro on the same source document, so I expected the same behavior at both computers.

    The part of the macro that is causing us problems is attached.

    Thanks for any suggestions you can provide!

    - Linda

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

    Re: Macro behaves differently on different computers (

    You might try to find out where the insertion point is when you start creating the new text for the footer, by looking at Selection.Information(wdHorizontalPositionRelative ToPage) and Selection.Information(wdVerticalPositionRelativeTo Page), for example by inserting Debug.Print statements or by using Debug | Add Watch. The expressions return a value in points, where 72 points = 1 inch.

    (Both the old and the new version work OK for me in Word 2002, I won't be able to test in Word 2003 until Monday; hopefully someone else will jump in).

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro behaves differently on different computers (

    it would also be interesting to know the value of Selection.Type at the time you have the problem.

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro behaves differently on different compute

    Unfortunately, I don't (at the moment) have access to my client's computer.

    I reinstated the problematic code at my computer so that I could see it fail, and here are the results of my test:

    <pre>debug.Print selection.Information(wdHorizontalPositionRelative ToPage)
    -1
    debug.print selection.Information(wdVerticalPositionRelativeTo Page)
    -1
    debug.Print selection.Type
    2
    debug.Print selection.Information(wdInHeaderFooter)
    True</pre>


    - Linda

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

    Re: Macro behaves differently on different compute

    The -1s mean that the selection is offscreen. I wonder what is going on. Could you post a copy of the document or template (zipped) in which most text has been removed or replaced with dummy text?

Posting Permissions

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