Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Can you write the contents of an Excel Named Range to Word?

Hi: I am looking for any assistance to write the contents of an Excel
Named Range to a Word doc at a book marked location. I have been able
to write code to write a single cell to a bookmark, but when I try to
write the contents of a range, I don't get any data, although I don't
get any errors either; just no text.

I am using code to create the named range and it seems to be set up
correctly in Excel after the routine runs.

I am wondering if my approach is wrong and I should just copy and
paste the data from Excel to Word instead, although I thought using a
named range might be more efficient instead of using the clipboard.

The data I am copying is not going to be more than probably 500 cells.

I have written a few macros, but still very much new to this. Any
help would be greatly appreciated!

Anne

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Can you write the contents of an Excel Named Range to Word?

It would help if you posted the code you already have.
--
HTH,
Barb Reinhardt



"Anne" wrote:

Hi: I am looking for any assistance to write the contents of an Excel
Named Range to a Word doc at a book marked location. I have been able
to write code to write a single cell to a bookmark, but when I try to
write the contents of a range, I don't get any data, although I don't
get any errors either; just no text.

I am using code to create the named range and it seems to be set up
correctly in Excel after the routine runs.

I am wondering if my approach is wrong and I should just copy and
paste the data from Excel to Word instead, although I thought using a
named range might be more efficient instead of using the clipboard.

The data I am copying is not going to be more than probably 500 cells.

I have written a few macros, but still very much new to this. Any
help would be greatly appreciated!

Anne


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Can you write the contents of an Excel Named Range to Word?

Thanks Barb. I wanted to simplify what I was doing. I removed the
steps to set up the named range and look for book marks. I did find a
way to write the data from the named range to a new Word doc with this
code, although I noticed even with a simple example of 3 columns and 3
rows, it still takes a few seconds to copy the data from Excel to
Word.

My ultimate goal is to have a spreadsheet with several tabs of data,
used for tracking project information (budget, status, risks, etc.),
then I want to generate a Word status report from the information in
the workbook. Since to accomplish my final project, I will need to
copy several tables from Excel to the Word doc, I want to make sure I
am doing it efficiently in terms of memory usage.

Here is the code I have that just opens a new doc and pastes in a
Named Range that I have set up manual in Excel.

Any advice to improve the process to get the table and pull it into
Word would be much appreciated.
---------------------

Sub CopyXLSDataToWord()

Dim WordApp As Word.Application
Dim WordDoc As Word.Document

' Create a Word document
Set WordApp = CreateObject("Word.Application")

' Make the newly created Word instance visible
WordApp.Visible = True

' Create a new document
Set WordDoc = WordApp.Documents.Add

' copy the range, assumes current excel active workbook
Range("TESTRANGE").Copy

' Paste as formatted text.
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF,
_
Placement:=wdInLine, DisplayAsIcon:=False

'This line also seems to work into paste the data - don't know if
one is better to use
'WordApp.Selection.PasteExcelTable False, False, True

' Clean up
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub

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
2007 - link named excel range to word document Karin Excel Discussion (Misc queries) 0 February 8th 10 09:36 PM
copying the contents of a named range from one location to another Steve Excel Discussion (Misc queries) 0 May 22nd 09 08:31 PM
Hyperlink to Named Range Based On Cell Contents TKS_Mark Excel Worksheet Functions 1 January 9th 08 04:14 PM
write a macro like the /file copy combine named range in lotus 12 surelystumped Excel Programming 5 September 25th 06 02:28 PM
Goto a named range using the contents of the active cell Brian C Excel Programming 1 June 14th 06 05:14 AM


All times are GMT +1. The time now is 05:01 AM.

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"