View Single Post
  #1   Report Post  
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.word.vba.userforms
[email protected] hornbecky83@gmail.com is offline
external usenet poster
 
Posts: 6
Default Link table from excel to word using word VBA

Hi-

I am new to VBA. I am making an automated report by copying excel
tables and pasting them in word. I want to use word VBA instead of
excel. I can get the tables to paste into word, but I can not get them
to be linked, so that when a parameter changes in excel it
automatically updates in my word document. The PasteExcelTable command
isn't working and I have the LinkedToExcel = true. I pasted my code
below. I am also having difficulty getting the excel table to paste
into the right document. I tried running the code in a module in the
document and also running the code in the document itself. But if
another word document is open, it sometimes pastes the table in the
other document. Can someone please help me!! Thank you in advance-
Sarah

Sub MissionDesignTemplate()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim strLVParameters As String
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Documents and
Settings\shornbec\Desktop\sarah\excel
templates\Mission.FY07Q1_Sarah.xls")

xlBook.Sheets("Report Tables").Range("LVParameters").Copy
Selection.PasteExcelTable LinkedToExcel:=True, WordFormatting:=False,
RTF:=False

xlBook.Close
xlApp.Quit

Set xlBook = Nothing
Set xlApp = Nothing
End Sub