Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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






  #5   Report Post  
Posted to microsoft.public.excel.programming
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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default 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









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a macro to open another document Bex Excel Discussion (Misc queries) 1 August 17th 07 02:20 AM
Using a macro to open another document CLR Excel Discussion (Misc queries) 0 August 17th 07 01:48 AM
Macro to open specific document Thew21 Excel Discussion (Misc queries) 1 December 13th 06 01:18 PM
Run a macro always I open an Excel Document Rui Álvares Excel Programming 1 July 20th 05 11:52 PM
macro and button to open a word document from within excel JAJOSEPHESQ Excel Programming 1 May 5th 04 06:06 AM


All times are GMT +1. The time now is 03:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"