locked
Resized image (inserted with IncludePicture field) reverts to original scaling in Word 2016 after saving, closing, re-opening and refreshing (using F9) RRS feed

  • Question

  • The user documentation we provide for our software (GoldSim) has 100s of images all inserted using IncludePicture fields. I have discovered that image resizing is not reliably preserved when using IncludePicture fields. This can be reproduced in a very simple way, as I describe below. (Note, we use Word 2016, but I think this problem has existed since Microsoft went to the XML-based .docx file format)

    NOTE: The majority of our images are scaled down to 70%. So the reversion to original scaling is a significant problem for us. We only recently converted our images from inserted pictures (using Insert->Pictures) to IncludePicture fields using a VBA script. The reason we did this is that the 'Links' dialog in Word only shows images in order if they are inserted using IncludePicture fields. Also, if we select an image in the document and then open the 'Links' dialog, it only selects/highlights the correct image in the list (in the 'Links' dialog) if the image was inserted using an IncludePicture field. We rely a lot on the 'Links' dialog when we have to replace images (for example when we release a new major version of the software and have to update screenshots).

    Here are steps for reproducing the issue:

    1) Save a new Word document in a test directory (e.g. C:\TEST). Put an image file in the same folder.

    2) Insert an IncludePicture field, providing the name of the image file in the 'Filename or URL' field. Make sure 'Data not stored with document' is selected and 'Preserve formatting during updates' is selected (all other check boxes should be unchecked). When you toggle to show the field code (using Alt-F9), it should look like this:

    { INCLUDEPICTURE  "image5_2.png" \d  \* MERGEFORMAT }

    But, I've also tried the following and observed the same issue:

    { INCLUDEPICTURE  "image5_2.png" \d  \* MERGEFORMATINET }

    3) Resize the image down to 50%, save and close the Word document.

    4) Re-open the Word document, select (i.e. left-click) the image and press F9 (to update/refresh). Note that the resizingsticks in this case. Save and close the Word document.

    5) Now, re-open the Word document, place your cursor somewhere in the document and type a line return, a character or a space (in other words, make an edit to the document that is unrelated to the inserted image). Then, save and close the Word document.

    6) When you re-open the document, select (i.e. left-click) the image and press F9 (to update/refresh). At this point, the image will **revert back to its original scaling. **If it does not revert back to original scaling, I've found that if I save, close and repeat step #5 and then step #6, the image will revert to original scaling. 

    At this point, the following are the only things I've found I can do to keep images from reverting to their original scaling:

    - Before saving and closing a file, always do a select all (Ctrl-A) and press F9 to update/refresh all images. Then, when I save, close, re-open and refresh, the scaling seems to stick. But, if we forget, then we lose our rescaling the next time we open and refresh.

    - Or, insert pictures by Insert->Pictures instead of IncludePicture fields. But, as I already explained, we need to use IncludePicture fields.

    - Or, never refresh the document (using F9).

    All three of these work-arounds are either very non-ideal or just not an option.

    Any other suggestions would be appreciated.

    Thanks,
    Ryan
    Friday, April 28, 2017 12:27 AM

All replies

  •  Hi RyanAGU,

    From the description of the thread , it looks like your issue is related with Word User interface.

    but you had posted the issue in Word for developers forum.

    for better support and better solution to resolve your issue , I move this thread to correct and best suitable Word it pro discussions forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 28, 2017 2:06 AM
  • You can constrain the image sizes (and the image resizing upon link update) by putting the INCLUDEPICTURE fields into single-celled tables with a fixed height and width.

    To create a single-cell table with a fixed height and width, use Insert|Table and choose one cell. Then, for the:
    • rows, set the exact row height under Table Tools>Layout>Properties>Row>Specify Height>Exactly.
    • columns, set the preferred column width under Table Tools>Layout>Properties>Columns,
    and uncheck the 'automatically resize to fit contents' option under Table Tools>Layout>Properties>Table>Options.

    A useful trick if you have multiple images to insert and you want to constrain them all to fit within a given size is to create & copy a single-cell table with a fixed height and width to wherever you want the images to go, then insert them into that.

    Of course, if the images are to appear in the document sequentially, perhaps with just a single line separating them, you could use a multi-row table. To automate the insertion of mutliple images (with captions), see: http://www.msofficeforums.com/word-vba/16772-4-digital-images-1-page.html#post47919. You could change 'LinkToFile:=False' in the code there to insert linked images.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, April 28, 2017 3:46 AM
  • Paul,

    Thanks for taking the time to reply. I have a couple of follow-up questions that I'll underline.

    Just to make sure I understand the situation, there is no way to resize a picture inserted using an IncludePicture field and have Word reliably preserve the resizing when repeatedly making edits to the document, saving, closing, re-opening and refreshing the document using F9. Is that right?

    If so, we have a pretty serious issue on our hands. I believe I can write a VBA script that would facilitate the task of going through the document and, image by image, retrieving the path and scaling information, deleting the image, inserting a one-cell table, sizing it appropriately, locking the size and reinserting the IncludePicture field.

    On top of that, though, we use MadCap Doc-to-Help (D2H) to generate PDF, HTML Help and NetHelp documentation. D2H uses Word notes/comments to flag text and images that should only conditionally be included (based on what target we're generating, PDF, HTML Help or NetHelp). When we delete an image that has a note attached to it, the note gets deleted as well. So I have to go back and re-add those notes. Our documentation is around 1700 pages long, and we have around 1400 to 1600 images perhaps that would need to be replaced.

    So, we really need to exhaust all other options. And I suspect the best option will be to *not* use IncludePicture fields, but rather go back to inserting pictures with Insert->Pictures. If I'm not mistaken, pictures inserted this way preserve their scaling.

    My question, then, centers around the original reason we stopped inserting pictures using Insert->Pictures. Each of our manuals is anywhere from 100 to 1000 pages and may include 100s of images. When we have to update a screenshot, we select it in the document and then open the 'links' dialog to get the name of the image. Then we know which one to replace.

    Let's say I have a document with the following five images:

    <Sorry, it made me delete my images before I can post>

    The order they appear in the document is 'Inserted4th', 'Inserted5th', 'Inserted1st', 'Inserted2nd', 'Inserted3rd'. In the document where I use IncludePicture fields, I can left click, say, the 'Inserted 5th' image and then open the 'Links' dialog and (1) the images are listed in the order in which they appear in the document and (2) the one I had selected ('Inserted 5th') is highlighted in the list in the 'Links' dialog.

    <Sorry, it made me delete my images before I can post>

    In contrast, in the document in which I use Insert->Pictures to insert all the pictures, if I do the same thing (i.e. left click the 'Inserted 5th' image in the document and then open the 'Links' dialog), (1) the images are listed in the wrong order (in this case, in the reverse order in which they appear in the document) and (2) it is always the top-most image in the list that's highlighted.

    <Sorry, it made me delete my images before I can post>

    My question is the following: If we go back to using Insert->Pictures to insert images into our documentation, do you know of a work-around for figuring out the name of an image that's selected in the document?

    Perhaps we could just write a simple VBA script that would tell us the name and path of a selected image. So we would just left-click an image in our document, run the script and a little dialog would pop up with this information.

    I appreciate your help.

    Ryan

    Saturday, April 29, 2017 12:58 AM
  • Unfortunately, you can't prevent a field from re-applying its own formatting when it updates; the behaviour is by design. All you can do with a linked image is to constrain the area within which it can resize. The use of fixed-dimension tables achieves that*. Alternatively, you could lock the INCLUDEPICTURE fields (Ctrl-F11) so they don't update, only unlocking particular INCLUDEPICTURE fields (Ctrl-Shift-F11) when they need updating (then doing whatever resizing is required and re-locking the field).

    As for your use of MadCap Doc-to-Help and the problem with note deletion, you might do better to conditionally hide the images rather than deleting them. If the images use any wrap format other than inline, you can do that by toggling their .Visible property. You might format inline images as hidden text. Yet another approach would be to have a custom document property or document variable for each image and embed the image (and its table if you use one) in an IF field that conditionally shows/hides the image (including an image inserted via an INCLUDEPICTURE field) according to the values of the custom document property or document variable. That way, users won't have hidden images displaying because they have Word configured to display hidden text.

    Another option that comes to mind for storing unlinked image names is to save the filenames as the 'Alternative Text' for each image. That makes it pretty easy to see which source file needs updating, but you'd still have to redo the scaling and re-apply the 'Alternative Text' any time you change the image. You are correct regarding unlinked images not re-scaling.

    * If only one dimension needs constraining (e.g. the height), fix only that dimension so you don't end up with tables dimensioned with aspect ratios that don't suit new images whose aspect ratios differ from the originals.

    PS: I note you mentioned the \* MERGEFORMAT and \* MERGEFORMATINET switches in your first post; you can delete those - they're not doing anything useful.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Proposed as answer by Steve Fan Monday, May 8, 2017 12:16 PM
    Saturday, April 29, 2017 3:58 AM
  • How important is the sequence in Edit Links?

    I'm just wondering whether selecting the picture, right-click and using Change Picture... works for you and would make use of the Edit Links option redundant. There is an irritating dialog that you have to use every time, but the folder it then opens seems to be "sticky", i.e. you probably wouldn't have to navigate through your folder structure every time you used it. The other problem is that if you want to link, you have to choose that option in the dropdown on the Insert button - Word does not automatically insert/link in the same way as the existing picture.

    As for the VBA side, even though you cannot see the image's pathname as you can with an INCLUDEPICTURE field, you should be able to get and modify the path of each linked picture. If the user selects a single picture, you should be able to get/change the path using

    Selection.InlineShapes(1).LinkFormat.SourceFullName

    (for inline pictures) or

    Selection.ShapeRange(1).LinkFormat.SourceFullName

    (for floating images)


    Peter Jamieson

    Saturday, April 29, 2017 2:47 PM