LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Opening Excel Workbook More Than Once

If you right click the wb.name and add a watch you can see what value is
being read. What I think is happening is the file specialone.xls has never
been saved. Excel when a file has been create and not saved the name doesn't
include the xls extension. Therefore you wer comparing "specilalone" with
specialone.xls and not getting a match.

This can be fixed by using the instr function.

if instr(ucase(findname),ucase(wb.name)) 1 then

You should determine why you have an unsaved workbook and determine if it is
appropriate that the file wasn't saved before you make any changes.

"Launchnet via OfficeKB.com" wrote:

Good Morning Joel . . . I appreciate the help.

The following is a copy of the code I used. Nothing Happens. Any Ideas ?
When I step thru it, the "Const findname ="specialone.xls" is skipped over.
When it gets to the If Found = True Then, it skips over the MsgBox and then
finishes.

Sub NewExcelWithWorkbookSpecialOne()

Const findname = "specialone.XLS"

Found = False
For Each Wb In Workbooks
If UCase(Wb.Name) = UCase(findname) Then
Found = True
Exit For
End If
Next Wb

If Found = True Then
MsgBox ("found file " & findname & " Do not open the file again")
End If

End Sub

Thanks
Matt@Launchnet




Joel wrote:
Try this

Sub getworkbooks()

Const findname = "BOOK1.XLS"

Found = False
For Each Wb In Workbooks
If UCase(Wb.Name) = UCase(findname) Then
Found = True
Exit For
End If
Next Wb

If Found = True Then
MsgBox ("found file " & findname & " Do not open the file again")
End If

End Sub

I have the following Macro that works, but I am trying to make it check to
see if the workbook is already open . . . and if it is open, to give the

[quoted text clipped - 65 lines]

End Sub


--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story. God Bless for everyones help.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200708/1


 
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
when opening an Excel Workbook, another blank workbook also opens Gord Dibben Excel Discussion (Misc queries) 0 October 12th 07 09:49 PM
when opening an Excel Workbook, another blank workbook also opens spmu Excel Discussion (Misc queries) 0 October 12th 07 01:46 PM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM
How to make the opening of a workbook conditional upon the opening of another workbook Marcello do Guzman Excel Programming 1 December 16th 03 06:09 AM
How to make opening of workbook conditional of opening of another workbook turk5555[_2_] Excel Programming 2 December 15th 03 11:07 PM


All times are GMT +1. The time now is 04:41 PM.

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"