Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using excel macro to activate word document

I have a bunch of data in Excel that I would like to copy
and paste into a Word document to create different
tables. I have written a macro in Word to format these
tables once the excel data is copied over.

Is there a way I can use an Excel macro to automatically
select a block of cells, copy and paste into Word, and
activate the Word macro?

Thanks,

Amy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default using excel macro to activate word document

If the Word macro is saved as "Macro1" in a template named MyTemplate.dot
and the range I want to copy over is A1:B2, the following would work (in
addition to editing to the range you really want, correct the path info for
templates on your PC)

Sub XLtoWord()
Range("A1:B2").Select
Selection.Copy

Dim bStarted As Boolean
Dim oApp As Object
Dim strPath As String

strPath = "C:\Documents and Settings\your ID\"
strPath = strPath & "Application Data\Microsoft\Templates\"

On Error Resume Next
Set oApp = GetObject(, "Word.Application")

If Err < 0 Then
bStarted = True
Set oApp = CreateObject("Word.Application")
End If

oApp.Activate
oApp.Visible = True
oApp.Documents.Add Template:=strPath & "MyTemplate.dot"
oApp.Selection.Paste

oApp.Run "Macro1"

If bStarted Then
oApp.Quit
End If

Set oApp = Nothing
End Sub


Steve


"Amy" wrote in message
...
I have a bunch of data in Excel that I would like to copy
and paste into a Word document to create different
tables. I have written a macro in Word to format these
tables once the excel data is copied over.

Is there a way I can use an Excel macro to automatically
select a block of cells, copy and paste into Word, and
activate the Word macro?

Thanks,

Amy



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
Reading Word document by using Excel Macro Arvind Mane Excel Discussion (Misc queries) 2 September 26th 08 07:55 AM
Opening a Word Document using an Excel (2000) Macro? ekreider Excel Discussion (Misc queries) 4 January 5th 08 04:41 AM
help creating a macro in excel that opens a specific word document Prohock Excel Discussion (Misc queries) 3 March 30th 06 04:58 PM
How do I activate Document Version management in Excel just like . Pradeep Khanna Excel Discussion (Misc queries) 0 April 22nd 05 10:30 AM
Embedded Word Document not painted until I click on it and activate it with the mouse Chad Knudson Excel Programming 1 July 23rd 03 09:58 PM


All times are GMT +1. The time now is 12:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"