Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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
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
macro to copy from excel range to word doc mopgcw Excel Discussion (Misc queries) 1 August 20th 07 07:54 PM
Copy from WORD to EXCEL using a macro..... Tee Excel Discussion (Misc queries) 1 March 1st 06 06:46 PM
Macro to copy a word doc into an excel doc Tee Excel Discussion (Misc queries) 0 February 22nd 06 12:01 PM
copy from Excel to Word by macro with certain for wmax77 Excel Discussion (Misc queries) 0 February 12th 06 11:33 AM
copy from Excel to word by macro with certain format wmax77 Excel Discussion (Misc queries) 0 February 9th 06 10:07 AM


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