+ Reply to Thread
Results 1 to 6 of 6

Word VBA to Open Excel File

  1. #1
    Forum Contributor
    Join Date
    09-23-2008
    Location
    UK
    Posts
    137

    Word VBA to Open Excel File

    Hi All,

    I want to open an excel file from word, using word vba. I want to send some data to and from as well.

    Tried this, but get "user defined object not defined"

    Please Login or Register  to view this content.
    Any ideas?

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Word VBA to Open Excel File

    Hi,

    I don't have much experience opening excel from word but try this:

    Please Login or Register  to view this content.
    Good luck.

    abousetta

  3. #3
    Forum Contributor
    Join Date
    09-23-2008
    Location
    UK
    Posts
    137

    Re: Word VBA to Open Excel File

    Hi, thanks for your response. It didn't quite work, but I got it going with the following:

    Please Login or Register  to view this content.
    I would now like to send data to excel, have that data update the sheet, then return the result to word. Any ideas!?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Word VBA to Open Excel File

    What data and where to?
    FYI, your original code would work fine if you set a reference (via Tools-References in the VB Editor) to the 'Microsoft Excel Object 11.0 Library'. The 11 is the version number, so 10 for Office XP, 12 for Office 2007, 14 for Office 2010.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Contributor
    Join Date
    09-23-2008
    Location
    UK
    Posts
    137

    Re: Word VBA to Open Excel File

    I want to take data from 16 text boxes in the Word doc, paste it to the named range "weights" in the first sheet of the excel workbook called "summary", this happens to be cells B31:B47. Then I want to take range C52:I69 and paste it back into word.

    I tried getting word to run an excel macro with:

    Please Login or Register  to view this content.
    but it doesn't like this.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Word VBA to Open Excel File

    Run is a method of the application, not workbook, so you need:
    Please Login or Register  to view this content.
    For the rest it would be useful to see sample documents. (Word VBA is not my thing, but I can probably cobble something together with a sample)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1