Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default VBA - Testing for Book1, Book2 etc.

Every day Quickbooks will create an excel file and depending on what is going
on on the user's system, it may be created as Book1, Book2 etc. In another
file on the user's machine, I'd like to create a macro that will save that
file to the network with a specific name. So I need a way of testing if
there is an open workbook called Book1, Book2 etc. There will only be one
Bookx file so if I find anything Bookx that's the one I need. Thanks for any
help on this.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default VBA - Testing for Book1, Book2 etc.

Paste the below function in your code and use it as

If Checkforworkbook ("Book25.xls") = True Then
'do something
End If

Function CheckforWorkbook(strSearch As String) As Boolean
Dim intTemp
For intTemp = 1 To Workbooks.Count
If InStr(1, Workbooks(intTemp).Name, strSearch, 1) < 0 Then
CheckforWorkbook = True: Exit Function
End If
Next
End Function
--
If this post helps click Yes
---------------
Jacob Skaria


"dhstein" wrote:

Every day Quickbooks will create an excel file and depending on what is going
on on the user's system, it may be created as Book1, Book2 etc. In another
file on the user's machine, I'd like to create a macro that will save that
file to the network with a specific name. So I need a way of testing if
there is an open workbook called Book1, Book2 etc. There will only be one
Bookx file so if I find anything Bookx that's the one I need. Thanks for any
help on this.

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
Transfer info book1 to book2 israel New Users to Excel 3 January 23rd 09 07:14 PM
Can I make a formula that always uses the latest wksht in Book2? grateful Excel Worksheet Functions 2 December 9th 08 05:18 PM
Book1 and Book2 JohnR Excel Discussion (Misc queries) 2 July 6th 07 02:10 AM
=SUMIF(book2!L3:AF3, "=book1!O30", book2!L20:AF20) dond Excel Discussion (Misc queries) 1 November 8th 05 12:33 PM
opens to Book2 maryj Excel Discussion (Misc queries) 0 April 13th 05 03:09 PM


All times are GMT +1. The time now is 02:23 AM.

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"