Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default check if file is already open

Hi,

I want a macro to check is a file, which is called upon, is already
open and if so skips the opening line of the code and proceeds with
the rest, otherwise proceed with opening the file.

Currently Excel asks me if I want to reopen the file and unsaved data
will be lost.

Cheers,

Harold

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default check if file is already open

Dim Wkbk as workbook
....

set wkbk = nothing
on error resume next
'don't use the drive/path here
set wkbk = workbooks("somename.xls")
on error goto 0

if wkbk is nothing then
'not open, so open it.
'you need the drive/path here
set wkbk = workbooks.open(filename:="C:\my documents\excel\somename.xls")
end if



mohavv wrote:

Hi,

I want a macro to check is a file, which is called upon, is already
open and if so skips the opening line of the code and proceeds with
the rest, otherwise proceed with opening the file.

Currently Excel asks me if I want to reopen the file and unsaved data
will be lost.

Cheers,

Harold


--

Dave Peterson
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
If Then to check if a workbook is open Shawn Excel Discussion (Misc queries) 5 November 25th 06 04:29 PM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
how do i check an open files size? Bri_paul Excel Discussion (Misc queries) 1 August 16th 06 04:45 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Check if workbook open dkipping Excel Discussion (Misc queries) 4 May 24th 06 02:00 PM


All times are GMT +1. The time now is 08:39 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"