Open Words doc from Excel Macro

  • Thread starter Thread starter Isham Hamin
  • Start date Start date
I

Isham Hamin

Hi,

New to the usergroup. Question: I'm trying to create an excel macro that
will pickup filename from a spreadsheet and open the file in Words
document, then do more formatting changes to the document. I seems to be
stuck at trying to open a Words document from an excel macro. Any
thoughts? Thanks in advance.

Isham
 
Try this... You need to reference your project to the "Microsoft Word ?.?
Object Library". In the VB Editor select Tools -> References ...

Sub OpenWordDoc()
Dim appWord As Word.Application

Set appWord = New Word.Application
With appWord
.Visible = True
.Documents.Open "D:\Test.doc"
End With
Set appWord = Nothing
End Sub
 
In A1 put, for example:
C:\third.doc
actually the path and filename of any Word doc. Then enter and run this
small macro:


Sub macro2()

Dim s As String
Dim ss As String
Dim sss As String

ss = "cmd.exe /c "
s = Cells(1, 1).Value
sss = ss & s
x = Shell(sss, 1)
End Sub

You will be in control in Word.
 

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

Back
Top