|
From: Raj on 24 Jun 2008 12:24 Hi, I have a word document (Document1) with five bookmarks. I have an excel workbook (Workbook1) with three sheets. I want to insert values from different cells in the excel workbook into the five bookmarks. The values in the excel workbook are placed in different cells in the three worksheets. What would the be the code to accomplish this? I assume the mail-merge option is out because it requires a list. The data here is scattered across the different worksheets. Thanks in advance for the help. Regards, Raj
From: StevenM on 24 Jun 2008 15:30 To: Raj, The basic idea is as follows: ' ' With the VBA editor at: Tools > Reference ' add: Microsoft Excel Object Library item ' Sub ReturnValueFromExcel() Dim oXL As Excel.Workbook Dim sFileName As String Dim sValue As String Dim sBookmark As String sFileName = "C:\Documents and Settings\Steven\Desktop\Book1.xls" sBookmark = "ThisBookmark" If Dir(sFileName) > "" Then Set oXL = GetObject(sFileName) sValue = CStr(oXL.Application.Range("A2").value) End If If ActiveDocument.Bookmarks.Exists(sBookmark) = True Then ActiveDocument.Bookmarks(sBookmark).Range.Text = sValue End If End Sub Steven Craig Miller "Raj" wrote: > Hi, > > I have a word document (Document1) with five bookmarks. I have an > excel workbook (Workbook1) with three sheets. I want to insert values > from different cells in the excel workbook into the five bookmarks. > The values in the excel workbook are placed in different cells in the > three worksheets. What would the be the code to accomplish this? > > I assume the mail-merge option is out because it requires a list. The > data here is scattered across the different worksheets. > > Thanks in advance for the help. > > Regards, > Raj >
|
Pages: 1 Prev: inserting blank line Next: remove warning when updating linked excel chart-objects |