ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can Macro command to open files? (https://www.excelbanter.com/excel-programming/402921-can-macro-command-open-files.html)

Berj

Can Macro command to open files?
 
Hi all,
can anybody help me with this?

I need a command to add at the beginning of a macro which can be executed
when my Excel file NAMES.XLS is opening. The macro should be part of NAMES.XLS
This command should open another file named Q1.XLS

The Result: when I open NAMES.XLS, the other file, Q1.XLS must be opened
with it too. Then NAMES.XLS be the active file once again.

Thanks in advance,
Berj

Gary''s Student

Can Macro command to open files?
 
Private Sub Workbook_Open()
ChDir "C:\Documents and Settings\Owner\Desktop\junk"
Workbooks.Open Filename:= _
"C:\Documents and Settings\Owner\Desktop\junk\Q1.xls"
Windows("NAMES.xls").Activate
End Sub

This goes in the NAMES.xls workbook code area.


Adjust the path to suite.
--
Gary''s Student - gsnu200761


"Berj" wrote:

Hi all,
can anybody help me with this?

I need a command to add at the beginning of a macro which can be executed
when my Excel file NAMES.XLS is opening. The macro should be part of NAMES.XLS
This command should open another file named Q1.XLS

The Result: when I open NAMES.XLS, the other file, Q1.XLS must be opened
with it too. Then NAMES.XLS be the active file once again.

Thanks in advance,
Berj



All times are GMT +1. The time now is 05:24 PM.

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