Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Is Active Workbook ="ABC"

Excel 2002, WinXP
I have a user-created menu item that is applicable to only one file. That
menu item is created/deleted by code that is in that one file. However,
other files may be open at the same time and I need to make sure that this
one file, "ABC", is the active file before executing the menu item code.
I thought that ThisWorkbook was always the active file but it isn't.
ThisWorkbook is the file that holds the macro that is being executed.
How do I check for the active file, as in:
If (the active file).Name < "ABC" Then MsgBox "Wrong File"
Thanks for your help. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Is Active Workbook ="ABC"

Otto,

Try something like

If ActiveWorkbook.Name < "ABC.xls" Then
' wrong file
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I have a user-created menu item that is applicable to only one

file. That
menu item is created/deleted by code that is in that one file.

However,
other files may be open at the same time and I need to make

sure that this
one file, "ABC", is the active file before executing the menu

item code.
I thought that ThisWorkbook was always the active file but

it isn't.
ThisWorkbook is the file that holds the macro that is being

executed.
How do I check for the active file, as in:
If (the active file).Name < "ABC" Then MsgBox "Wrong File"
Thanks for your help. Otto




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Is Active Workbook ="ABC"

Thanks Chip. I knew it had to be something simple. Otto
"Chip Pearson" wrote in message
...
Otto,

Try something like

If ActiveWorkbook.Name < "ABC.xls" Then
' wrong file
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I have a user-created menu item that is applicable to only one

file. That
menu item is created/deleted by code that is in that one file.

However,
other files may be open at the same time and I need to make

sure that this
one file, "ABC", is the active file before executing the menu

item code.
I thought that ThisWorkbook was always the active file but

it isn't.
ThisWorkbook is the file that holds the macro that is being

executed.
How do I check for the active file, as in:
If (the active file).Name < "ABC" Then MsgBox "Wrong File"
Thanks for your help. Otto






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Is Active Workbook ="ABC"

have you tried Windows("ABC.xls").Visible = True

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Is Active Workbook ="ABC"

Hi Otto;

Use the call

ActiveWorkBook.Name

It might look something like this:

Sub Try ()

If ActiveWorkBook.Name = "MyWorkBookName" then
'do your menu stuff here
End If
End Sub


-----Original Message-----
Excel 2002, WinXP
I have a user-created menu item that is applicable to

only one file. That
menu item is created/deleted by code that is in that one

file. However,
other files may be open at the same time and I need to

make sure that this
one file, "ABC", is the active file before executing the

menu item code.
I thought that ThisWorkbook was always the active

file but it isn't.
ThisWorkbook is the file that holds the macro that is

being executed.
How do I check for the active file, as in:
If (the active file).Name < "ABC" Then MsgBox "Wrong

File"
Thanks for your help. Otto


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Is Active Workbook ="ABC"

I responded but I haven't seen it posted. I'll try again. Otto

Thanks Chip. I knew it had to be something simple. Otto

"Chip Pearson" wrote in message
...
Otto,

Try something like

If ActiveWorkbook.Name < "ABC.xls" Then
' wrong file
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I have a user-created menu item that is applicable to only one

file. That
menu item is created/deleted by code that is in that one file.

However,
other files may be open at the same time and I need to make

sure that this
one file, "ABC", is the active file before executing the menu

item code.
I thought that ThisWorkbook was always the active file but

it isn't.
ThisWorkbook is the file that holds the macro that is being

executed.
How do I check for the active file, as in:
If (the active file).Name < "ABC" Then MsgBox "Wrong File"
Thanks for your help. Otto






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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Can I keep "Windows of active workbook check box" checked SueH Excel Discussion (Misc queries) 1 February 15th 07 07:38 PM
cannot use "Create List" and "Share Workbook" same time Devendra Excel Discussion (Misc queries) 0 October 26th 06 06:05 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


All times are GMT +1. The time now is 01:22 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"