Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to open a file(2) when I open file(1) and then close file(1)
File(1) name can change so I need variables. sequence will be Open File(1) Open File(2)... I do it by the following macro: Public LaunchFile As String 'in this public variable I want to keep file(1) name Private Sub Workbook_Open() Dim lDir, lFile, lFileMtr As String lDir = Sheets("launch").Range("B2") & "\" 'direction of my file to open lFile = Sheets("launch").Range("B3") & ".xls" 'file name to openm lFileMtr = lDir & lFile 'complete string of file(2) LaunchFile = ThisWorkbook.Name 'filename file(1) Workbooks.Open Filename:=lFileMtr, ReadOnly:=True End Sub then on file(2) I have Private Sub Workbook_Open() msgbox LaunchFile 'I did it to be sure value stays but it is blank so next line fail. workbooks(LaunchFile).close false End Sub Any idea where am I failing? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Close & save a file at set time only IF the file is open | Excel Programming | |||
Close Current File Then Open New file | Excel Programming | |||
OPen and close file | Excel Programming | |||
VBA - on a button event, open another closed file, post changes, close file | Excel Programming | |||
Automate open file, update links, run macro, close and save file | Excel Programming |