Consulting

Results 1 to 12 of 12

Thread: Insert and link shapes from Excel to Word that updates

  1. #1
    VBAX Regular
    Joined
    May 2018
    Posts
    14
    Location

    Insert and link shapes from Excel to Word that updates

    Hello!

    So I have been working some in vba in Excel but now I need to make a more automated report in Word and cant really get a hang of updating shapes.


    So for example on the front page I want a normal rectangular shape with text. the text needs to be linked to either a cell or the original shape in an Excel file. I have tried to copy paste the shape as an graphic object and run this macro but that dosent work. I found that I cant paste a shape as a link.

    I would have thought this thing would have been easier sine it should be fairly common that someone needs to link stuff from excel etc



    This code is what I currently have for updating text and graphs.

    Sub UpdateText()'
    
    ThisDocument.InlineShapes(1).LinkFormat.Update
    
    
    ActiveDocument.Fields.Update
    
    
    On Error Resume Next
    
    
        Dim iShp As Word.InlineShape
        For Each iShp In ActiveDocument.InlineShapes
            iShp.LinkFormat.Update
        Next
        
    End Sub


    Next problem:

    I also have a chart that I run a macro on and format the colors on (a wind rose). The simple update macro dont work which I assumed it wouldnt since it is the formatting that changes and not the values. Any idea how I get the formatting to update?
    Last edited by Johan90; 07-19-2018 at 07:15 AM.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Is the problem object formatted as inline or wrapped? Is it set to auto-update? Do you have Word configured to 'update automatic links at open'?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    May 2018
    Posts
    14
    Location
    Ok I think the shapes with text would be wrapped, as in floating? And, the wind rose chart would be inline.

    For the first they are just normal rectangular shapes were the text is linked to a cell. The second problem object is just an inserted doughnut chart with (a few too many rings haha), I then wrote code to color all the separate sections to make a wind rose. So its a chart with static figures but one that gets its color reformatted.

    Another way to put it, can Word auto update a charts color formatting on a chart that is linked to Excel?
    Last edited by Johan90; 07-20-2018 at 06:25 AM.

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Johan90 View Post
    Another way to put it, can Word auto update a charts color formatting on a chart that is linked to Excel?
    All the formatting would be inherited from Excel. If you try applying formatting from within Word, it will be lost every time the link is refreshed.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    VBAX Regular
    Joined
    May 2018
    Posts
    14
    Location
    Ok I think managed to click around to a solution for the formatting issue. I used the paste as link and as a bitmap, it updates new formatting and the actual values for the graph.


    But I still have no clue about getting a shape to update its text? When I go into the paste menu in word the paste as link option is closed.

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    If the entire chart is linked, including any legends, the text is inherited from the link; you can't update/edit it independently.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #7
    VBAX Regular
    Joined
    May 2018
    Posts
    14
    Location
    The legends update fine in the linked charts, but I also I want to link separate shapes, for instance a front page title.


    Or can I link text from the document to the head title shape? Kind of how you do in Excel by typing in a cell reference in the shape.

  8. #8
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Johan90 View Post
    also I want to link separate shapes, for instance a front page title.
    And where is that - in the workbook or in the document?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  9. #9
    VBAX Regular
    Joined
    May 2018
    Posts
    14
    Location
    In the document. The idea is to have a workbook that runs some calculations and imports some data that then can be linked into Word and printed from there. I found that it is easier to make the formal layout in word.

  10. #10
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Linking within a Word document is done via bookmarks & cross-references. You can't bookmark part of a linked object, so you also can't cross-reference it; you would need to create another link to the relevant data in the source. You can however, bookmark an entire linked object and insert a cross-reference to the bookmark, so that the linked object appears in multiple locations.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  11. #11
    VBAX Regular
    Joined
    May 2018
    Posts
    14
    Location
    Do you know a guide or something that can walk me through the process? I am very unfamiliar with the Word enviroment and have limited knowledge of working in it

  12. #12
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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