1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Embedding an edited excel sheet in word.

Discussion in 'Archive: Business Applications' started by ranon, Sep 22, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. ranon

    ranon Thread Starter

    Joined:
    Jan 2, 2005
    Messages:
    6
    I need to embed an excel sheet into word quite regularly. It looks like the sample document given. Generally only the price changes but the formulas remain the same.

    Is there some word macro that can accomplish this?
     

    Attached Files:

  2. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Have you tried Paste Link?

    Copy your range in Excel. Switch to Word, then Edit > Paste Special. For "As", highlight Excel Worksheet Object, and select Paste Link. You should see info that says "changes to the source will be reflected in your document", so ... "auto-updating".

    Welcome to the board.
     
  3. ranon

    ranon Thread Starter

    Joined:
    Jan 2, 2005
    Messages:
    6
    Yes, that would work.

    A macro to copy - paste would make the job a lot easier. I could use some help on that.
     
  4. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Since the table in your doc is dynamically linked to the source (table in Excel), I don't see how.

    Is there some other info you've not shared? (such as data in Excel may vary in size or has a variable location)
     
  5. ranon

    ranon Thread Starter

    Joined:
    Jan 2, 2005
    Messages:
    6
    Its not dynamically linked. An embedded copy paste (static) is what I want. After pasting each word document will change the prices and other minor formatting as required.
     
  6. ranon

    ranon Thread Starter

    Joined:
    Jan 2, 2005
    Messages:
    6
    The data in Excel has a fixed location and a range to copy from.

    (This is basically a sheet that I create myself for convenience)
     
  7. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Yeah, I do understand what you're saying (now), but I'm struggling for a best method.

    What I like the look of is ... a "template" doc (not an actual template) with the table in, and a bookmark defined for the table.

    Then you can use Insert > File, and specify the bookmark (say "Table") as the range to insert. That way, the source doc needn't be opened at any time.

    That translates as a fairly simple Word macro:

    Sub test()
    Selection.InsertFile FileName:="test.doc", Range:="table", _
    ConfirmConversions:=False, Link:=False, Attachment:=False
    End Sub


    although, you might need to define the path to test.doc if its directory doesn't match your current doc.

    Let me test it some more.
     
  8. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    This seems to work:

    Sub test()
    ChangeFileOpenDirectory "C:\Documents and Settings\Andy\My Documents\"
    Selection.InsertFile FileName:="test.doc", Range:="table", _
    ConfirmConversions:=False, Link:=False, Attachment:=False
    End Sub


    You'd need to insert it in an added module under Project - Normal in the Word VBE*. Do you know how to do that?

    *after which you could probably assign it to a toolbar button.
     
  9. ranon

    ranon Thread Starter

    Joined:
    Jan 2, 2005
    Messages:
    6
    I tested it out. It works.

    I added it as a macro in the normal template. I will give it a shortcut key, maybe add it to the ribbon.

    Thanks a million. This will save me a lot of work. I am already going to tweak it a little, e.g. have 2-3 macros for different flavors of tables. Thanks again.
     
  10. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    (y)

    I'm sure you realise that you could store the different tables in a single "template" doc, so long as each one has its own bookmark for the macros to identify.

    Use Thread Tools at the top of the page to mark this Solved if you wish. :)
     
  11. ranon

    ranon Thread Starter

    Joined:
    Jan 2, 2005
    Messages:
    6
    That was the idea. It's a nice, clean solution. (y) (y)
     
  12. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/752237

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice