View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Todd Todd is offline
external usenet poster
 
Posts: 177
Default macro to open a document

Thanks! This is closer. I am sorry that I don't know more and can just fix
it. This opens a my excel file as a word doc. How do I get it to open it in
excel? I tried replacing the text "word" with "excel" but as I am sure you
know, it didn't work.


Thanks again,

Todd


"Penny Miller" wrote:

Try this;

Dim appWord As Object
Dim myDoc As Object
Set appWord = CreateObject("Word.Application")
Set myDoc = appWord.Documents.Open("C:\MyFiles\MyDoc.xls")

"Todd" wrote in message
...
Ok, Thanks.

From that I have this statement below. I am getting "a user defined type
not defined error with the dim statement". I am looking at the library
for
excel types and don't know which one to choose?

Thanks.

Sub opendoc()
Dim MyDoc As Excel.xls
'Set MyDoc = Excel.Documents.Open("C:\MyFiles\MyDoc.xls")
End Sub




"Penny Miller" wrote:

Read the responses to Michelle Hanan's Opening doc in macro that was
posted
on 7/12

"Todd" wrote in message
...
How do I write a macro to open a document? I tried to record a macro
and
go
this macro that selects a cell and follows a hyperlink. But I would
like
to
put the address of the doc. into the macro and not have the hyperlink
in a
cell on the document.

Sub OpenTemplate()
Range("AH1").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
ActiveWindow.ActivateNext
End Sub


Thanks,


Todd