Getting Word to work with Excel

  • Thread starter Thread starter mike.wasson
  • Start date Start date
M

mike.wasson

Hi all,
I'm trying to use VBA to coordinate Word and Excel. I know that to
do so, you need to configure something under Tools->References.
Unfortunately, when I look under the Tools menu, References is grayed
out--does anyone know why this might be, and what I'd have to do to
enable it?

Thanks,
Mike
 
Oops, sorry for the double-post...anyway, if it helps, I'm using
Microsoft Office Word/Excel SP2, with Visual Basic 6.3.
 
It would be greyed out if you were stepping through the macro?

However, you shouldn't need to add the reference - just use the
following code


Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
'if not adding a new document in your process, add it now
as this
'method would give an instance of Word WITHOUT a doc!
End If
appwd.Visible = True
On Error GoTo 0
With appwd
'do what you want
end with
 
Do you have a workbook open and it is the activeproject. References are
particular to a workbook - not the excel application.
 

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