ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   URGENT: switch excel workbooks and display msgbox (https://www.excelbanter.com/excel-programming/330941-urgent-switch-excel-workbooks-display-msgbox.html)

ilyaskazi[_15_]

URGENT: switch excel workbooks and display msgbox
 

switch to all open workbooks apart from activeworkbook and othe
windows.

On switching check whether file "MYFILE.xls" is opened or not an
display msgbox saying "MYFILE is opened" else "Not opened"

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=37652


JMB

URGENT: switch excel workbooks and display msgbox
 
Sub TestMyFile()
Const FileName As String = "myfile.xls"
Dim x As Workbook
Dim FileOpen As Boolean

FileOpen = False
For Each x In Workbooks
If UCase(x.Name) = UCase(FileName) Then _
FileOpen = True
Next x

If FileOpen Then
MsgBox "MyFile is open"
Else: MsgBox "MyFile is not open"
End If

End Sub


"ilyaskazi" wrote:


switch to all open workbooks apart from activeworkbook and other
windows.

On switching check whether file "MYFILE.xls" is opened or not and
display msgbox saying "MYFILE is opened" else "Not opened".


--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=376525



Tushar Mehta

URGENT: switch excel workbooks and display msgbox
 
Well, since someone has already done what looks like a homework
assignment... {grin}

Function FileIsOpen(Filename As String) As Boolean
On Error Resume Next
FileIsOpen = Not (Workbooks(Filename) Is Nothing)
End Function
Sub testIt2()
MsgBox FileIsOpen("book2")
MsgBox FileIsOpen("xxxxxx")
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

switch to all open workbooks apart from activeworkbook and other
windows.

On switching check whether file "MYFILE.xls" is opened or not and
display msgbox saying "MYFILE is opened" else "Not opened".


--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile:
http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=376525




All times are GMT +1. The time now is 10:14 PM.

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