Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Auto Open Macro

Hi,

I have a spreadsheet that I want to open automatically when I open a
specific file. I'm not sure how to do that. Any help would be appreciated!

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Auto Open Macro

If I understand the question correctly you want the spreadsheet to (without
being open) "listen" for the target file being opened, and then open itself,
which it just can not do. There are a couple of alternatives.

You could set it up that when you open the Excel file the other file will
open, or you could use a batch file as a shortcut to open both files
simultaneously.
--
HTH...

Jim Thomlinson


"Kasey Kern" wrote:

Hi,

I have a spreadsheet that I want to open automatically when I open a
specific file. I'm not sure how to do that. Any help would be appreciated!

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Auto Open Macro

Workbook #1 wants workbook #2 open when you open #1?

You could open workbook #2.
Hit alt-f11 to get to the VBE.
Click on workbook #2' project.
It should look like: VBAProject (Workbook2.xls)
Hit F4 to see the properties window

Change the (Name) property to something nice and unique (not VBAProject).

Maybe the name of the workbook (nicely truncated)????

Save that workbook.

Back to excel to open workbook #1
back to the VBE (alt-f11)
click on workbook #1's project
then Tools|references
select the project for workbook #2.

Back to excel and close both (remember to save workbook #1).

Now open workbook #1. Since you have a reference to #2, it'll be opened when #1
opens.

=========
Alternatively, you could use a macro that tries to open workbook #2.

Option Explicit
Sub Auto_open()

Dim tstWkbk As Workbook
Set tstWkbk = Nothing
On Error Resume Next
Set tstWkbk = Workbooks("workbook2.xls")
On Error GoTo 0

If tstWkbk Is Nothing Then
On Error Resume Next
Set tstWkbk = Workbooks.Open(Filename:="C:\my documents\workbook2.xls")
On Error GoTo 0
If tstWkbk Is Nothing Then
MsgBox "File not found!"
End If
End If
End Sub

Change the names.


Kasey Kern wrote:

Hi,

I have a spreadsheet that I want to open automatically when I open a
specific file. I'm not sure how to do that. Any help would be appreciated!

Thanks!


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Auto Open Macro

Thanks for responding. I wanted spreadsheet B to open when I opened
spreadsheet A. I used the following code and it worked..

Private Sub Workbook_Open()
Workbooks.Open Filename:="C:\B.xls"
End Sub

Thanks!

"Jim Thomlinson" wrote:

If I understand the question correctly you want the spreadsheet to (without
being open) "listen" for the target file being opened, and then open itself,
which it just can not do. There are a couple of alternatives.

You could set it up that when you open the Excel file the other file will
open, or you could use a batch file as a shortcut to open both files
simultaneously.
--
HTH...

Jim Thomlinson


"Kasey Kern" wrote:

Hi,

I have a spreadsheet that I want to open automatically when I open a
specific file. I'm not sure how to do that. Any help would be appreciated!

Thanks!

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
Auto Open Macro Launchnet Excel Worksheet Functions 7 July 20th 07 07:41 PM
Error with Auto Open Macro David Excel Programming 4 August 1st 05 11:46 PM
open up an excel program with an auto open macro [email protected] Excel Programming 2 July 17th 05 04:48 PM
Auto run macro on *.csv file open CP Poe Excel Programming 4 March 4th 05 06:25 PM
Auto run macro on open file Diane Alsing Excel Programming 2 February 16th 05 02:05 PM


All times are GMT +1. The time now is 08:10 PM.

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"