View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
stratuser stratuser is offline
external usenet poster
 
Posts: 21
Default Open One Word File from Excel

Thanks, that did the trick.

-----Original Message-----
Use GetObject. This will return an existing Word

application. If
it returns Nothing, then use CreateObject to create a new
instance of Word. E.g.,

Dim WordObj As Object
Set WordObj = GetObject(, "Word.Application") 'note

leading comma
If WordObj Is Nothing Then
Set WordObj = CreateObject("Word.Application")
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Stratuser" wrote in
message ...
Thanks, but that doesn't work either, because I don't

want
to create a new instance of Word each time I run this
subroutine. If I use CreateObject("word.application") I
get a new instance every time I call the procedure.


-----Original Message-----
Stratuser,

you can try this.

Sub copyexceltoword()

Set wd = CreateObject("word.application")
wd.Application.Visible = True
wd.Application.Documents.Open "c:\matt.doc" ' Open your

word document
Application.Visible = True

For a = 1 To 5

Application.Range("a" & a).Copy 'copy data from excel
wd.Selection.Paste 'Paste data into

word
Next a



Set wd = Nothing 'Clear the memory. Very important.


End Sub


let me know if you need further help.


---
Message posted from http://www.ExcelForum.com/

.



.