Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send multi data (Graph/Cell data) to Word doc as 1 item (no cells) Tom-LE Excel Discussion (Misc queries) 0 August 30th 06 10:10 PM
send document from Excel to Word in readable form BillyG Excel Discussion (Misc queries) 4 May 2nd 06 12:46 AM
My send to in excel/word does not offer send as attachment Mstink Excel Discussion (Misc queries) 11 March 16th 06 02:49 PM
how to send documents from document imaging to word? JBHarriman Excel Discussion (Misc queries) 0 January 30th 05 07:31 PM
macro to send data from word to excel tory04 Excel Programming 1 November 18th 03 05:43 PM


All times are GMT +1. The time now is 11:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"