Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Send data to Word document
This seems like a very easy task, but I just can't seem to get started. I
have an Excel spreadsheet that has lots of data. I want to programically send data from the spreadsheet to the existing Word document. Step 1: Open the file. The full path of the file is in cell A1. Step 2: Export data. For instance, I need cell A5 data to be placed at the bookmark named "Inflation." The data in cell A6 needs to be placed at the bookmark named "Return" Thanks for any help!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Send data to Word document
On Fri, 27 Feb 2004 23:55:18 -0600, "Tizz" wrote:
This seems like a very easy task, but I just can't seem to get started. I have an Excel spreadsheet that has lots of data. I want to programically send data from the spreadsheet to the existing Word document. Step 1: Open the file. The full path of the file is in cell A1. Step 2: Export data. For instance, I need cell A5 data to be placed at the bookmark named "Inflation." The data in cell A6 needs to be placed at the bookmark named "Return" This is fairly rudimenatary (especially in error handling) but it should get you started. First, in Excel's Visual Basic Editor go to the Tools menu - References item, and find the Microsoft Word Object Library for your version of Word. Check the box next to it. Now you can use this: Sub ExportDataToWord() Dim wdApp As Word.Application Dim wdDoc As Word.Document If Dir(Range("A1").Value, vbNormal) = "" Then MsgBox "The file specified in cell A1 cannot be found." Exit Sub End If Set wdApp = CreateObject("Word.Application") wdApp.Visible = True Set wdDoc = wdApp.Documents.Open(Range("A1").Value) With wdApp .Selection.GoTo What:=wdGoToBookmark, Name:="Inflation" .Selection.TypeText Text:=Range("A5").Value .Selection.GoTo What:=wdGoToBookmark, Name:="Return" .Selection.TypeText Text:=Range("A6").Value End With Set wdDoc = Nothing Set wdApp = Nothing End Sub --------------------------------------------------------- Hank Scorpio scorpionet who hates spam is at iprimus.com.au (You know what to do.) * Please keep all replies in this Newsgroup. Thanks! * |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Send data to Word document
Thank you!!!
"Hank Scorpio" wrote in message ... On Fri, 27 Feb 2004 23:55:18 -0600, "Tizz" wrote: This seems like a very easy task, but I just can't seem to get started. I have an Excel spreadsheet that has lots of data. I want to programically send data from the spreadsheet to the existing Word document. Step 1: Open the file. The full path of the file is in cell A1. Step 2: Export data. For instance, I need cell A5 data to be placed at the bookmark named "Inflation." The data in cell A6 needs to be placed at the bookmark named "Return" This is fairly rudimenatary (especially in error handling) but it should get you started. First, in Excel's Visual Basic Editor go to the Tools menu - References item, and find the Microsoft Word Object Library for your version of Word. Check the box next to it. Now you can use this: Sub ExportDataToWord() Dim wdApp As Word.Application Dim wdDoc As Word.Document If Dir(Range("A1").Value, vbNormal) = "" Then MsgBox "The file specified in cell A1 cannot be found." Exit Sub End If Set wdApp = CreateObject("Word.Application") wdApp.Visible = True Set wdDoc = wdApp.Documents.Open(Range("A1").Value) With wdApp .Selection.GoTo What:=wdGoToBookmark, Name:="Inflation" .Selection.TypeText Text:=Range("A5").Value .Selection.GoTo What:=wdGoToBookmark, Name:="Return" .Selection.TypeText Text:=Range("A6").Value End With Set wdDoc = Nothing Set wdApp = Nothing End Sub --------------------------------------------------------- Hank Scorpio scorpionet who hates spam is at iprimus.com.au (You know what to do.) * Please keep all replies in this Newsgroup. Thanks! * |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Send multi data (Graph/Cell data) to Word doc as 1 item (no cells) | Excel Discussion (Misc queries) | |||
send document from Excel to Word in readable form | Excel Discussion (Misc queries) | |||
My send to in excel/word does not offer send as attachment | Excel Discussion (Misc queries) | |||
how to send documents from document imaging to word? | Excel Discussion (Misc queries) | |||
macro to send data from word to excel | Excel Programming |