Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Keeping name of worksheet who called macro

I have a pair of workbooks. One is created by a coworker, mine provides a
number of utilities back to the coworker's workbook.

Coworker's workbook has a name "VLAPPI". My workbook is titled "Scenarios".

My coworker has graciously included code in ThisWorkbook to call my workbook
upon startup or activation. My workbook addes a menu of my utilities to the
VLAPPI workbook.

In one of the utilities I provide , a new file is created, activated,
renamed, and saved. After saving the new file I need to get back to the
VLAPPI workbook.

The problem is the file may not necessarilty be called VLAPPI. It coould
have some other name. I don't know how to active that workbook if it is
under a different name.

Right now I'm using Windows("VLAPPI.xls").Activate

But if the name is different this blows up.

How can I set a public variable for the workbook that the menu selection was
made from to run my utility and that will work regardless of the name of my
coworker's workbook? So if the work book is named "VLAPPX" I can reactive
the "calling" workbook "VLAPPX" when my utility has run its course.

Would it help if I told him he can change the name but the first two letters
had to be "VL"?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Keeping name of worksheet who called macro

The workbook activating your workbook would be the one to set any variables.

Try this:

Dim TempBook As Workbook
For Each TempBook In Workbooks
'Check for something here that always exists and is unique
If TempBook.BuiltinDocumentProperties("Author").Value = '"coworker's name"
Then
tempbook.activate
MsgBox ("Here's the workbook: " & TempBook.Name)
Exit For
End If
Next

Ken V.

"Dkline" wrote in message
...
I have a pair of workbooks. One is created by a coworker, mine provides a
number of utilities back to the coworker's workbook.

Coworker's workbook has a name "VLAPPI". My workbook is titled

"Scenarios".

My coworker has graciously included code in ThisWorkbook to call my

workbook
upon startup or activation. My workbook addes a menu of my utilities to

the
VLAPPI workbook.

In one of the utilities I provide , a new file is created, activated,
renamed, and saved. After saving the new file I need to get back to the
VLAPPI workbook.

The problem is the file may not necessarilty be called VLAPPI. It coould
have some other name. I don't know how to active that workbook if it is
under a different name.

Right now I'm using Windows("VLAPPI.xls").Activate

But if the name is different this blows up.

How can I set a public variable for the workbook that the menu selection

was
made from to run my utility and that will work regardless of the name of

my
coworker's workbook? So if the work book is named "VLAPPX" I can reactive
the "calling" workbook "VLAPPX" when my utility has run its course.

Would it help if I told him he can change the name but the first two

letters
had to be "VL"?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Keeping name of worksheet who called macro

How are your utilities executed?

I understand that your coworker uses the Workbook_Open
event to call your workbook. Does he open your workbook
and then execute a procedure in it?

Have him do something like this:

Private Sub Workbook_Open()
dim util as Workbook
set util = Workbooks.Open("C:\Ultility.xls")
Call util.CopyFile(ThisWorkbook.Name)
End Sub

Then have your "CopyFile" subroutine use the Workbook name
argument.

HTH.
-Brad
-----Original Message-----
I have a pair of workbooks. One is created by a coworker,

mine provides a
number of utilities back to the coworker's workbook.

Coworker's workbook has a name "VLAPPI". My workbook is

titled "Scenarios".

My coworker has graciously included code in ThisWorkbook

to call my workbook
upon startup or activation. My workbook addes a menu of

my utilities to the
VLAPPI workbook.

In one of the utilities I provide , a new file is

created, activated,
renamed, and saved. After saving the new file I need to

get back to the
VLAPPI workbook.

The problem is the file may not necessarilty be called

VLAPPI. It coould
have some other name. I don't know how to active that

workbook if it is
under a different name.

Right now I'm using Windows("VLAPPI.xls").Activate

But if the name is different this blows up.

How can I set a public variable for the workbook that the

menu selection was
made from to run my utility and that will work regardless

of the name of my
coworker's workbook? So if the work book is

named "VLAPPX" I can reactive
the "calling" workbook "VLAPPX" when my utility has run

its course.

Would it help if I told him he can change the name but

the first two letters
had to be "VL"?


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Keeping name of worksheet who called macro

In the macro assigned to your menu item

Sub MyMenuButton1_click()
Dim wkbk = Activeworkbook
- do all your work
wkbk.Activate
End Sub

--
Regards,
Tom Ogilvy

"Dkline" wrote in message
...
I have a pair of workbooks. One is created by a coworker, mine provides a
number of utilities back to the coworker's workbook.

Coworker's workbook has a name "VLAPPI". My workbook is titled

"Scenarios".

My coworker has graciously included code in ThisWorkbook to call my

workbook
upon startup or activation. My workbook addes a menu of my utilities to

the
VLAPPI workbook.

In one of the utilities I provide , a new file is created, activated,
renamed, and saved. After saving the new file I need to get back to the
VLAPPI workbook.

The problem is the file may not necessarilty be called VLAPPI. It coould
have some other name. I don't know how to active that workbook if it is
under a different name.

Right now I'm using Windows("VLAPPI.xls").Activate

But if the name is different this blows up.

How can I set a public variable for the workbook that the menu selection

was
made from to run my utility and that will work regardless of the name of

my
coworker's workbook? So if the work book is named "VLAPPX" I can reactive
the "calling" workbook "VLAPPX" when my utility has run its course.

Would it help if I told him he can change the name but the first two

letters
had to be "VL"?




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
How to change the macro called by an add in from older excel? Ian Excel Discussion (Misc queries) 2 June 25th 08 10:53 PM
SIZE Window, Tile, Worksheet, Workbook, Whatever it's called. JamesInNeedFootballInDeed New Users to Excel 4 October 31st 07 11:16 PM
Returning an Array from a called function within a macro [email protected] New Users to Excel 1 May 18th 07 03:47 PM
which FormField called a macro? Juggernath[_2_] Excel Programming 0 January 15th 04 12:58 PM
Called macro runs twice in excel 2002 Tom Ogilvy Excel Programming 1 September 10th 03 02:12 PM


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