+ Reply to Thread
Results 1 to 2 of 2

exporting Excel data to MS Word...

Hybrid View

  1. #1
    Registered User
    Join Date
    07-27-2007
    Posts
    2

    Question exporting Excel data to MS Word...

    My question is related to both Excel and MS Word, but I guess people here should know the answer - I think this is done fairly simple, but I'm in a big hurry...

    I need to create a field in MS Word containing data from a single Excel worksheet cell, for example B2, so that every time I update the worksheet and open the MS Word document, the Word document is also updated.

    I tried to do this using "Import Database" but it always ends up importing an entire row (database record). I could create a backup worksheet and arrange the data so that there is only the data I need in a specific row, but I would like to avoid this, as I already have a complex enough worksheet.

    Thanks very much in advance.

  2. #2
    Registered User
    Join Date
    07-27-2007
    Posts
    2

    Thumbs up Problem solved!

    Problem solved, thanks to mr. P. Jovanovic from elitesecurity.org forums... Using this macro, I was able to import specific data into my Word document - this was a one-time operation.

    Sub PasteLink()
    '
    ' PasteLink Macro
    ' Makro otvara Excel tabelu i na izabrani opseg kopira na
    ' tekucu poziciju u aktivnom word dokumentu
    '
    ' P.Jovanovic za elitisecurity.org
    ' 19/02/2007
    '
    Dim xlApp As Excel.Application
    Dim rngTemp As Excel.Range
    Dim wkb As Excel.Workbook
    Dim FilePath As String

    ' Open Excel table
    Set xlApp = New Excel.Application ' Runs Excel
    FilePath = "C:\Temp\Test.xls"
    Set wkb = xlApp.Workbooks.Open(FileName:=FilePath, ReadOnly:=True)
    xlApp.Visible = True
    ' Select copy range
    Set rngTemp = xlApp.InputBox("Selektuj opseg za kopiranje", "Copy Link", Type:=8)
    rngTemp.Copy
    ' Paste to Word document
    Selection.PasteSpecial Link:=True, DataType:=wdPasteRTF, Placement:= _
    wdInLine, DisplayAsIcon:=False
    ' Close Excela
    xlApp.DisplayAlerts = False ' to avoid save dialog
    xlApp.Quit
    xlApp.DisplayAlerts = True
    Set xlApp = Nothing
    End Sub


    Be sure to check MS Excel... Reference Library while Macro editing in Word (Tools/References)

+ 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