+ Reply to Thread
Results 1 to 5 of 5

[Solved] VBA to export data from Excel to Word - help!

  1. #1
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    [Solved] VBA to export data from Excel to Word - help!

    Hello all,

    My workbook is slowly coming along thanks to all the help on this forum, but I'm now truly befuddled.

    Sheet 5 (named RESULTS) has data appended to it in table form using a VBA - basically it copies certain cells from another sheet and adds these to the next empty row in RESULTS sheet.

    This starts at B2 and uses 6 columns (so B2 to G2). There are a variable amount of rows depending on how many tests are done (so the range will be B2 to Gx).

    What I want to do is for excel to open a word template (C:\test.dot) and put the info from B2 - Gx into table form into Word. But I can't do it! I've tried Professor Google but everyone else's code doesn't seem to work for me.

    Oh - it's excel 2003 I'm using (my employers too tight to upgrade!)

    Many thanks.
    Last edited by wonderdunder; 10-25-2010 at 03:43 PM.

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: VBA to export data from Excel to Word - help!

    Can you post the test.dot so we can fix it up to do what you need?
    Bob
    Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.

  3. #3
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    Re: VBA to export data from Excel to Word - help!

    I've managed to do it now, thanks.

    However, I do need help in getting to paste the data to a specific location on the worksheet.

    I'll post what I have tomorrow when back at work.

    Thanks.

  4. #4
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    Re: VBA to export data from Excel to Word - help!

    Well, erm, I've sorted that one too! But anyway, here's the code in case it can be of use to anyone else (and if anyone can improve please feel free!). I do need help on another matter though so there will be yet another plea for help!

    Private Sub CommandButton1_Click()

    'copy range from b2 to last cell
    Range("b2", Range("b2").End(xlToRight).End(xlDown)).Copy

    'select word
    Dim wdapp As Word.Application
    Set wdapp = GetObject(, "word.application")

    'select bookmark in word named fromexcel and paste there
    With wdapp.Selection
    wdapp.Selection.GoTo What:=wdGoToBookmark, Name:="fromexcel"
    Paste

    End With



    End Sub

  5. #5
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: VBA to export data from Excel to Word - help!

    go ahead and mark this thread [SOLVED] and start a new one with other questions.

+ 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