• Home
  • Blog
  • Resume
  • Contact
  • Projects
  • Gallery
  • Amit’s Resume
  • About Nagpur
KEEP IN TOUCH

To check if a workbook is open, if it’s not open it

Mar03
2005
Leave a Comment Written by admin

This Procedure will ask for a file name to the user, will check if the file is open and if it’s not open it will open the file otherwise give a message to the user.

Public Sub IsWorkbookOpen()
Dim Wb As Workbook, wkbk As Variant
‘get the dialog box to open the file
wkbk = Application.GetOpenFilename(“Excel Files,*.xls”)
If wkbk = False Then Exit Sub
‘check if its already opened in the Windows collection
Dim flag As Boolean
flag = False
For Each Wb In Workbooks
If Wb.Path & “\” & Wb.Name = wkbk Then
MsgBox “File is already open”, vbExclamation, “Workbook Open”
Wb.Activate
flag = True
End If
Next Wb
If flag = False Then Workbooks.Open (wkbk)
End Sub

Related posts:

  1. Change the creation date of a workbook
  2. Isworksheetopen and Isworkbookopen functions
Posted in Uncategorized - Tagged Path Wb, Workbook Open Wb
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Super-Easy Guide to the Microsoft Office Excel 2003 Object Model
» PMT Worksheet Function

No Comments Yet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Tags

Access Alt F8 Books boxplot cells charts count cursor dashboard data mining dbase design error excel excel functions export filter flip LaTex MS query Number Err ODBC pipes Press Alt F11 Public Sub python R random numbers Range Cells report scripting software sparklines SQL SQL server stack columns statistics stemming string tag cloud text mining UDF VBA visualization wildcard

Network

View Ashutosh Nandeshwar's profile on LinkedIn

Recent Comments

  • W. McNabb on The search key was not found in any record in Access
  • Manuel on The search key was not found in any record in Access
  • Wendy Naples on The search key was not found in any record in Access
  • larry on Access Export to Excel (2007)
  • Betty Chou on Projects

Related Posts

  1. Change the creation date of a workbook
  2. Isworksheetopen and Isworkbookopen functions

EvoLve theme by Blogatize  •  Powered by WordPress nandeshwar.info