Results 1 to 4 of 4

Thread: [RESOLVED] Word Textbox Anchoring to Page Instead of Margin Using docx Format

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    14

    Resolved [RESOLVED] Word Textbox Anchoring to Page Instead of Margin Using docx Format

    Greetings,

    We have a Visual Basic 6.0 application that creates Word documents. It uses a textbox to place certain header and footer content on the page and uses the Word 14.0 object library (Word 2010). We were using FileFormat:=wdFormatDocument on the SaveAs function and getting a .doc file. Everything was working fine. Then we switched to using FileFormat:=wdFormatXMLDocument in order to get a .docx format. The problem is now those textboxes appear to be anchoring themselves to the page, not the margin, so everything is off by 1". On the textboxes we are using:
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
    but have also tried other settings without any luck.

    Is anyone familiar with this and know of a work-around?

    Thanks,
    Jeff

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Word Textbox Anchoring to Page Instead of Margin Using docx Format

    Ive not used it. Not had the need. But, just a thought, when you create your anchor, is there some object or elelment you apply it to?

    If you set the left margin manually, or adjust one manually, can you see where the anchor is, or the values used to display..?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Word Textbox Anchoring to Page Instead of Margin Using docx Format

    if you have added an inline shape, i believe you have to convert it to a shape, though i have no idea why it would be different between the word document versions, if you post the full code, someone could have a look
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    14

    Re: Word Textbox Anchoring to Page Instead of Margin Using docx Format

    Thank you for your responses. For some reason I didn't get notified that there were responses to my question and just now saw them for the first time.

    I ended up putting in some "padding" to the offset of the textboxes in order to get them in the right location. It seems to be working fine.

    Thanks again, much appreciated,
    Jeff

Posting Permissions

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



Click Here to Expand Forum to Full Width