Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Word Relative Field Paths Discussion II - MERGEFORMAT

    Hello,

    First of all, I would like to thank Macropod, whose macro posted in this link has been of great help to me.

    My situation now is the following: I have a .docm Word file with the macro. It works great, except for the fact that the linked text fields change their format every time they are updated.

    Now, comment #40 in the discussion thread about this macro refers to another thread, where Macropod says (comment #5):
    You'd probably do well to delete the \* MERGEFORMAT switches - they're unlikely to do anything useful and could actually make things go awry in some cases.
    Although I am not working with headers or footers, I just tried with an old version of my document, before I implemented the macros. One of the objects' links looks like this:
    Code:
    LINK Excel.Sheet.8 C:\\Users\\igavuzzo\\Documents\\Dropbox\\template_modelados\\test3_autoupdate\\Sfnet_FSDS.xlsm FSDS!fsds_labname \t  \* MERGEFORMAT
    When I take "\* MERGEFORMAT" out of the link, I also lose format. This is why I dare to contradict Macropod, thinking I actually need to keep that part of the link so the format is not lost.

    I am using MS Word 2007 on Windows 7.

    Can anyone shed some light on how should the macro be modified in order to keep text format the way it is before execution?

    Thank you so much.
    Ivo

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,879
    Thanks
    0
    Thanked 182 Times in 167 Posts
    Hi Ivo,

    The \t switch in your field code says to import the content as plain text, so I'm not sure what formatting you're referring to.

    Typically, the '\* Mergeformat' switch will be added automatically after you apply, say, bold formatting to the field. The common problem with this switch is that, if your named range (FSDS!fsds_labname) or the data it outputs expands beyond what was originally given that format, the new data may not have the same format. That's what I meant when I said the '\* Mergeformat' switch is liable to make things go awry. If you need to control the formatting (i.e. use something other than the underling paragraph Style) ,it's far better to apply the desired format to the 'L' lin 'LINK' and use a '\* Charformat' switch. As it is, though, the code doesn't delete the '\* Mergeformat' switch, so you can leave it there if you prefer.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #3
    New Lounger
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi Paul!

    Thanks for your help.

    What I did was:

    1) Paste the linked field. Format in the xlsx spreadsheet for that cell is Verdana, size 16.
    2) Format the result to Verdana, size 16, bold, after which I get this "\* MERGEFORMAT", just as you said.

    Now, if I replace the path manually and keep "\* MERGEFORMAT", it works fine. It changes the information displayed, and keeps the format as it was. I get the same if I use "\* CHARFORMAT".

    However, if I execute the macro, MERGEFORMAT or CHARFORMAT are removed, and field is correctly updated. I go from this:
    Code:
    LINK Excel.Sheet.8 C:\\Users\\user\\Documents\\Dropbox\\template_modelados\\release_1.1\\Sfnet_FSDS.xlsm FSDS!fsds_labname \t  \* MERGEFORMAT
    to this:
    Code:
    LINK Excel.Sheet.8 "C:\\Users\\user\\Documents\\Dropbox\\template_modelados\\test3_autoupdate\\Sfnet_FSDS.xlsm" "FSDS!fsds_labname" \a \t
    ...but now format is ARIAL 24!

    The reason why I am using \t is that I thought this would be the best choice to bring plain text and format it in the Word document (and forget the format in the xlsx file). And it actually works, if I don't take MERGEFORMAT or CHARFORMAT out.

    Unfortunately, formatting the L in LINK will not do much for me either, because when I press ALT+F9 to see the actual links, the format I see is not ARIAL 24, but VERDANA 16.

    Any suggestions?

    I truly appreciate your help!
    Ivo
    Last edited by igavuzzo; 2014-01-28 at 14:18.

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,879
    Thanks
    0
    Thanked 182 Times in 167 Posts
    I don't understand how that could be happening, as there is nothing in the code to affect anything other than the filepath - it doesn't even look at any of the switches used in the field.

    As for the change in font size, that's probably happening because the Style definition for the paragraph you're inserting the field into specifies a 24pt font, but you've tried to override the definition with hard formatting. That's poor practice and can lead to bloated & corrupt documents. Note also that the \t switch tells Word to ignore the source formatting; if you want to preserve the source formatting, instead of '\a \t' your field should use '\a \f 4 \r'.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. The Following User Says Thank You to macropod For This Useful Post:

    igavuzzo (2014-01-29)

  7. #5
    New Lounger
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I don't understand why that is being removed either.

    You were right again! Correcting styles fixed my problem. I would have never guessed they were that important.

    Thank you so much!
    Ivo

Tags for this Thread

Posting Permissions

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