Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Cut/Paste TextBox (Word XP)

    I have some code that reviews the header of a document and makes updates if necessary. If the current logo is not in the header, I add the logo. As part of the process, I anchor a text box to paragraph 1; it was previously anchored to paragraph 2. To do this, I cut the text box, select paragraph 1, and paste. The text box has always pasted at its previous position, i.e. left and top alignment remaining the same. For one user out of about 600, the text box is going to the center of the page when pasted.

    Is there some obscure Word setting that is causing this to happen, or could it be a corrupt Word Data Key or something of that nature. The code has been in use for nearly 2 years without a problem. I'm stumped by this situation. I want to put the text box where it was... not at a particular location. I could ge the top and left values before cutting and compare afterwards, but I think it makes more sense to identify the problem.

    Does anyone know of a setting which would cause Paste to put a text box at a location other than its original?

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

    Re: Cut/Paste TextBox (Word XP)

    I doubt that you'll ever find out the exact cause. I don't think it's corruption (although I can't rule that out), it might be the result of what this particular user has recently done with shapes/text boxes. Lesson: don't asume that Word will always behave the way it usually does...

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Cut/Paste TextBox (Word XP)

    A persistent colleague discovered something, and I pursued it further. If the Office Clipboard task pane is visible (in Word, or even in Excel), the pasted object goes to the middle of the page. If the Office Clipboard is not visible, everything is good. (This is also true in 2003 and 2007.)

    In OfficeXP, there's apparently no way to determine if the Clipboard is visible. I recorded a macro to see what I came up with, and the code was WordBasic.EditOfficeClipboard. That displays the clipboard pane, but that appears to be the only action that can be performed. Do you know of anything else?

    Thanks,
    Richard

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

    Re: Cut/Paste TextBox (Word XP)

    > I could ge the top and left values before cutting and compare afterwards,

    I think this is what you will have to do. Even if you find a way to get the behaviour you want there is no guarantee that a future minor patch won't change the behaviour again.

    StuartR

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

    Re: Cut/Paste TextBox (Word XP)

    I cannot reproduce the behavior that you describe - even with the Clipboard task pane visible, text boxes aren't pasted in the middle of the page.

    Anyhow, you could hide the task pane:

    ' Variable to hold current task pane status
    Dim blnVisible As Boolean
    ' Store current status
    blnVisible = CommandBars("Task Pane").Visible
    ' Hide task pane
    CommandBars("Task Pane").Visible = False
    ' Do your stuff
    ...
    ' Restore original status
    CommandBars("Task Pane").Visible = blnVisible

    See Word’s Task Panes VBA Reference if you want to feel frustrated about handling task panes in VBA.

  6. #6
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Cut/Paste TextBox (Word XP)

    I've been working/testing in a header, but after your observation, I see that if I cut/paste in the main document I do not have the problem.

    I think the best thing to do is check the left/top positions. The top position should be 7.1 inches, and that always proves false because of the way Word stores the values. I can test for < InchesToPoints(7.0) and that will let me know I need to reposition.

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

    Re: Cut/Paste TextBox (Word XP)

    I tested both in the main document and in a header, but couldn't reproduce the behavior that you described in either situation. That doesn't imply that you're wrong, it just emphasizes what Stuart and I wrote before: you cannot rely on Word behaving the same for all users/in all situations, so it's best to always set the position of the pasted text box.

Posting Permissions

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