Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Check to see if a file is already open

Hi all

I have a proceedure that opens a certain file the problem is that when the
proceedure is run again it reopens the file where it loses some information,
is there a way to check to see if that file is already open?

Thanks in Advance

Jason
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Check to see if a file is already open

Hi Jason

This will check every open workbook by it's name. If your workbook is
already open it will return True in the variable fileopen.

Dim FileOpen As Boolean
Dim wb As Workbook
FileOpen = False
For Each wb In Application.Workbooks
If wb.Name = "NameOfYourWorkbook.xls" Then
FileOpen = True
Exit For
End If
Next 'wb

Regards
Ingolf

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Check to see if a file is already open

On Error Resume Next
Set owb = Workbooks("myFile.xls")
On Error GoTo 0
If Not owb Is Nothing Then
MsgBox "Workbook is alraedy open"
Else
Set owb = Workbooks.Open("myFile.xls")
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jason Zischke" wrote in message
...
Hi all

I have a proceedure that opens a certain file the problem is that when the
proceedure is run again it reopens the file where it loses some

information,
is there a way to check to see if that file is already open?

Thanks in Advance

Jason



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
How to check for Open File! Ayo Excel Discussion (Misc queries) 2 August 11th 08 06:55 PM
check if file is already open mohavv Excel Discussion (Misc queries) 1 October 15th 07 12:08 AM
check if a file is open C[_4_] Excel Programming 6 March 31st 06 03:28 PM
File Open Check dthmtlgod Excel Programming 1 January 13th 06 02:51 PM
check if file already is open Mats Nilsson Excel Programming 2 September 12th 05 09:30 AM


All times are GMT +1. The time now is 04:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"