Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pasting in selected cells | Excel Discussion (Misc queries) | |||
excel check boxes moving when excel selected cells pasted in word | Excel Discussion (Misc queries) | |||
How do I copy selected cells in excel and paste into word table | Excel Programming | |||
remove paddings in cells when pasting from excel to word? | Excel Discussion (Misc queries) | |||
Pasting single cells from Word to multiple cells in Excel | Excel Worksheet Functions |