ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to open a document (https://www.excelbanter.com/excel-programming/369281-macro-open-document.html)

Todd

macro to open a document
 
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

Penny Miller

macro to open a document
 
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




Todd

macro to open a document
 
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





Penny Miller

macro to open a document
 
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







Todd

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







Penny Miller

macro to open a document
 
I guess I must have misunderstood you, I thought you needed to open a
document not a workbook. Instead try this code;

Sub OpenWorksheet()
'
' Opens Worksheet Macro
' Macro recorded 8/3/2006
'
Workbooks.Open Filename:="C:\MyFiles\MyWorksheet.xls"
End Sub


"Todd" wrote in message
...
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









Todd

macro to open a document
 
That does it! Thank you so much for your patience.

Todd

"Penny Miller" wrote:

I guess I must have misunderstood you, I thought you needed to open a
document not a workbook. Instead try this code;

Sub OpenWorksheet()
'
' Opens Worksheet Macro
' Macro recorded 8/3/2006
'
Workbooks.Open Filename:="C:\MyFiles\MyWorksheet.xls"
End Sub


"Todd" wrote in message
...
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











All times are GMT +1. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com