![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 94
|
I have a macro which opens a specific file. I would like to check to see if that file is open so that there is no error on running the macro. I would like something along the lines of If workbook x is open then activate workbook X else open workbook x end if Thanks Stewart |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Something like this would work. I don't know if there's anything more efficient though.
HTH |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
This one works too. I like the other version as you can use a variable.
If 'some code Workbooks.Open FileName:= _ "\serverfoldersheet.xls", _ updatelinks:=3, WriteResPassword:="pw" 'check to see if read only If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Saved = True ActiveWorkbook.Close end if |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|