open word file

R

Ranjith Kurian

Hi

i would like to open word file using getopenfilename by using excel macro
and copy the data to excel file.

Sub test()
Dim appWD As Word.Application
Dim appWDS As Word.Document
Set appWD = CreateObject("Word.Application.8")
appWD.Visible = True
filetoopen = Word.Application.GetOpenFilename("All Files (*.*),*.*")
Workbooks.Open filetoopen
end sub
 
T

thexlguy

Here you go. This works. It's not exactly like your code, but you ge
the idea. The "text to be pasted" should be replaced with text fro
your Excel file. Let me know if you need help getting the text fro
your excel file via VBA.

Sub PasteIntoWordDoc()

Dim wrd As Object

Set wrd = CreateObject("Word.Application")
wrd.documents.Open "C:\test.doc"
wrd.Visible = True

'MsgBox (wrd.documents.Item(1).Name)

wrd.documents.Item(1).Range(Start:=0, End:=0).Text = "text to b
pasted"
Set wrd = Nothing

End Sub

Thanks,
Mike

'TheXLGuy.com Excel Heat Maps' (http://thexlguy.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top