Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
select all & copy in word from macro in excel
Hello,
I'm using excel to create a new document in word. When the word document is created I would like to select all and copy. Can I do this from the excel macro? Many thanks in advance for any help, -- Regards, Lindstrom |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
select all & copy in word from macro in excel
sure, you'll have to check the Microsoft Word Object Library. Then you can
use all the word VBA objects in your module in excel. -- KB If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. --Albert Einstein "fitful_thought" wrote in message ... Hello, I'm using excel to create a new document in word. When the word document is created I would like to select all and copy. Can I do this from the excel macro? Many thanks in advance for any help, -- Regards, Lindstrom |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
select all & copy in word from macro in excel
Hi. Then you can use "OLE Automation". How about trying this macro?
Sub CopyFromWord() Dim wordApp As Object Dim wordDoc As Object 'started the Word Set wordApp = CreateObject("Word.Application") With wordApp .Visible = True .WindowState = wdWindowStateNormal .Documents.Add Set wordDoc = .ActiveDocument End With 'inserted arbitrary text (is able to omit) With wordApp.Selection .InsertAfter "Created time: " .InsertAfter Now() End With '[Select All] and [Copy] With wordApp.Selection .WholeStory .Copy End With 'pasted to this worksheet "sheet1" ThisWorkbook.Sheets("sheet1").Range("A1").PasteSpe cial xlPasteValues 'saved word document wordDoc.SaveAs "test.doc" wordDoc.Close 'quitted the Word wordApp.Quit Set wordDoc = Nothing Set wordApp = Nothing End Sub SAMURA "fitful_thought" wrote in message ... Hello, I'm using excel to create a new document in word. When the word document is created I would like to select all and copy. Can I do this from the excel macro? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
select all & copy in word from macro in excel
Arigato Samura,
-- Regards, Lindstrom "SAMURA" wrote in message ... Hi. Then you can use "OLE Automation". How about trying this macro? Sub CopyFromWord() Dim wordApp As Object Dim wordDoc As Object 'started the Word Set wordApp = CreateObject("Word.Application") With wordApp .Visible = True .WindowState = wdWindowStateNormal .Documents.Add Set wordDoc = .ActiveDocument End With 'inserted arbitrary text (is able to omit) With wordApp.Selection .InsertAfter "Created time: " .InsertAfter Now() End With '[Select All] and [Copy] With wordApp.Selection .WholeStory .Copy End With 'pasted to this worksheet "sheet1" ThisWorkbook.Sheets("sheet1").Range("A1").PasteSpe cial xlPasteValues 'saved word document wordDoc.SaveAs "test.doc" wordDoc.Close 'quitted the Word wordApp.Quit Set wordDoc = Nothing Set wordApp = Nothing End Sub SAMURA "fitful_thought" wrote in message ... Hello, I'm using excel to create a new document in word. When the word document is created I would like to select all and copy. Can I do this from the excel macro? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro to copy from excel range to word doc | Excel Discussion (Misc queries) | |||
Copy from WORD to EXCEL using a macro..... | Excel Discussion (Misc queries) | |||
Macro to copy a word doc into an excel doc | Excel Discussion (Misc queries) | |||
copy from Excel to Word by macro with certain for | Excel Discussion (Misc queries) | |||
copy from Excel to word by macro with certain format | Excel Discussion (Misc queries) |