Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pasting Selected Excel Cells into a Word Doc

Hi.

I need to generate reports in Word, where the content of those reports
is copied from selected parts of an Excel spreadsheet.

Please provide detailed guidance on creating an Excel macro to:
A. Paste selected cells from an Excel XLS into a new Word doc.
B. Run Word VBA code (via the same Excel macro) to reformat those
cells in Word.

More specifically ...

A. I need the Excel macro to:
(1) Copy the currently selected cells onto the Windows clipboard.
(2) Open Word and start a fresh document.
(3) Paste the contents of the clipboard into the new Word doc.

B.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Pasting Selected Excel Cells into a Word Doc

I don't know which clipboard is used he

Sub place_into_Word()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Selection.Copy
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add

With wrdDoc
wrdApp.Selection.PasteAndFormat (wdPasteDefault)
If Dir("C:\Temp\whatever.doc") < "" Then
Kill "C:\Temp\whatever.doc"
End If
.SaveAs ("C:\Temp\whatever.doc")
.Close
End With
wrdApp.Quit
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub

--
Gary''s Student - gsnu2007k


"Dave" wrote:

Hi.

I need to generate reports in Word, where the content of those reports
is copied from selected parts of an Excel spreadsheet.

Please provide detailed guidance on creating an Excel macro to:
A. Paste selected cells from an Excel XLS into a new Word doc.
B. Run Word VBA code (via the same Excel macro) to reformat those
cells in Word.

More specifically ...

A. I need the Excel macro to:
(1) Copy the currently selected cells onto the Windows clipboard.
(2) Open Word and start a fresh document.
(3) Paste the contents of the clipboard into the new Word doc.

B.
(1) Let me run a Word macro (already recorded) that reformats that
Excel content as a Word table.
(2) Big question here is -- once I've done as per item "A" above --
how do I (can I?) get Excel to recognize code that was recorded as
Word VBA, and run that code in the Excel (macro) environment?

Thanks very much,
Dave

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
Pasting in selected cells saz2369 Excel Discussion (Misc queries) 2 January 19th 09 02:13 PM
excel check boxes moving when excel selected cells pasted in word Erik Excel Discussion (Misc queries) 0 July 7th 06 05:00 PM
How do I copy selected cells in excel and paste into word table REVA Excel Programming 2 January 4th 06 09:43 PM
remove paddings in cells when pasting from excel to word? kpascal Excel Discussion (Misc queries) 0 November 4th 05 10:27 PM
Pasting single cells from Word to multiple cells in Excel ASBiss Excel Worksheet Functions 1 February 15th 05 11:47 AM


All times are GMT +1. The time now is 05:25 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"