Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DRK DRK is offline
external usenet poster
 
Posts: 40
Default Passing calling workbook name to called workbook

I have two workbooks - I'll call them Main and Compliance. Compliance is used
solely to print the legal compliance stuff. Main handles the concept stuff
and printing the concept stuff.

My custom menu in Main calls a print macro in Compliance. When that macro is
done, I want to activate the Main workbook. The problem is the Main Workbook
name can be different so I can't hard code the name into Compliance code to
activate the Main workbook.

The end users want to save each Main workbook under a different name to
preserve their cases.

How can I send or carry over the name of the Main workbook with what ever is
its current name to the Compliance workbook?

--
DRK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Passing calling workbook name to called workbook

You could always have it loop through the workbooks collection and examine
each workbook to find a unique identifying characteristic.

Assume only the main workbook will have a defined name "Main"

Dim bk as workbook, nm as Name
for each bk in application.workbooks
on error resume next
set nm = bk.Names("Main")
On error goto 0
if not nm is nothing then
bk.activate
end if
Next

--
Regards,
Tom Ogilvy

"DRK" wrote:

I have two workbooks - I'll call them Main and Compliance. Compliance is used
solely to print the legal compliance stuff. Main handles the concept stuff
and printing the concept stuff.

My custom menu in Main calls a print macro in Compliance. When that macro is
done, I want to activate the Main workbook. The problem is the Main Workbook
name can be different so I can't hard code the name into Compliance code to
activate the Main workbook.

The end users want to save each Main workbook under a different name to
preserve their cases.

How can I send or carry over the name of the Main workbook with what ever is
its current name to the Compliance workbook?

--
DRK

  #3   Report Post  
Posted to microsoft.public.excel.programming
DRK DRK is offline
external usenet poster
 
Posts: 40
Default Passing calling workbook name to called workbook

My problem is they renamed the Main workbook to "Watson". Within "Watson" can
I set a variable to the workbook's name and pass that value to the Compliance
workbook?
--
DRK


"Tom Ogilvy" wrote:

You could always have it loop through the workbooks collection and examine
each workbook to find a unique identifying characteristic.

Assume only the main workbook will have a defined name "Main"

Dim bk as workbook, nm as Name
for each bk in application.workbooks
on error resume next
set nm = bk.Names("Main")
On error goto 0
if not nm is nothing then
bk.activate
end if
Next

--
Regards,
Tom Ogilvy

"DRK" wrote:

I have two workbooks - I'll call them Main and Compliance. Compliance is used
solely to print the legal compliance stuff. Main handles the concept stuff
and printing the concept stuff.

My custom menu in Main calls a print macro in Compliance. When that macro is
done, I want to activate the Main workbook. The problem is the Main Workbook
name can be different so I can't hard code the name into Compliance code to
activate the Main workbook.

The end users want to save each Main workbook under a different name to
preserve their cases.

How can I send or carry over the name of the Main workbook with what ever is
its current name to the Compliance workbook?

--
DRK

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Passing calling workbook name to called workbook

Hi,

basically, you can have
1)public variable with workbook name
2)pass the name as one of arguments while calling your printing
procedure

Regards,
Ivan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Passing calling workbook name to called workbook

You said:

My custom menu in Main calls a print macro in Compliance.


Is this a commandbar button?

What do you mean by custom menu

what do you mean by calls a print macro in compliance

A public variable in Main will not be visible in Compliance unless you set a
reference from Compliance to main, so I don't know what Ivan is suggesting
there. I don't see a reference as being feasible in the situation you
describe.

Passing an argument is not really supported if this is a commandbar button.
If you are calling a procedure in Compliance from a procedure in Main using
application.run, then you could pass an argument, but your description didn't
seem to indicate this. Again, your participation in describing the
particulars is applicable.

So maybe if you provide some more information you can get a suggestion that
is compatible with your situation.

The suggestion I provided is applicable in any imaginable scenario by the
way.

--
Regards,
Tom Ogilvy







"DRK" wrote:

My problem is they renamed the Main workbook to "Watson". Within "Watson" can
I set a variable to the workbook's name and pass that value to the Compliance
workbook?
--
DRK


"Tom Ogilvy" wrote:

You could always have it loop through the workbooks collection and examine
each workbook to find a unique identifying characteristic.

Assume only the main workbook will have a defined name "Main"

Dim bk as workbook, nm as Name
for each bk in application.workbooks
on error resume next
set nm = bk.Names("Main")
On error goto 0
if not nm is nothing then
bk.activate
end if
Next

--
Regards,
Tom Ogilvy

"DRK" wrote:

I have two workbooks - I'll call them Main and Compliance. Compliance is used
solely to print the legal compliance stuff. Main handles the concept stuff
and printing the concept stuff.

My custom menu in Main calls a print macro in Compliance. When that macro is
done, I want to activate the Main workbook. The problem is the Main Workbook
name can be different so I can't hard code the name into Compliance code to
activate the Main workbook.

The end users want to save each Main workbook under a different name to
preserve their cases.

How can I send or carry over the name of the Main workbook with what ever is
its current name to the Compliance workbook?

--
DRK



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Passing calling workbook name to called workbook

Hi Tom,

Sorry I wasn't clear.

I meant that public variable in Compliance (which is always the same
workbook) may be visible to Main (with reference to Compliance) and
that it is possible to assign value to it from Main.

Regards,
Ivan

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Passing calling workbook name to called workbook

You don't need to pass the workbook name. Give your Main project
a new Project Name (in VBA, with the Main project active, go to
the Tools menu, choose "VBAProject Properties" and give the
project a new name like MainProject). Then, in the Compliance
workbook code, use

Application.VBE.VBProjects("MainProject").VBCompon ents("ThisWorkbook").Activate


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






"DRK" wrote in message
...
I have two workbooks - I'll call them Main and Compliance.
Compliance is used
solely to print the legal compliance stuff. Main handles the
concept stuff
and printing the concept stuff.

My custom menu in Main calls a print macro in Compliance. When
that macro is
done, I want to activate the Main workbook. The problem is the
Main Workbook
name can be different so I can't hard code the name into
Compliance code to
activate the Main workbook.

The end users want to save each Main workbook under a different
name to
preserve their cases.

How can I send or carry over the name of the Main workbook with
what ever is
its current name to the Compliance workbook?

--
DRK



  #8   Report Post  
Posted to microsoft.public.excel.programming
DRK DRK is offline
external usenet poster
 
Posts: 40
Default Passing calling workbook name to called workbook

I had to turn on "Trust access to Visual Basic Project " and then it worked.
--
DRK


"Chip Pearson" wrote:

You don't need to pass the workbook name. Give your Main project
a new Project Name (in VBA, with the Main project active, go to
the Tools menu, choose "VBAProject Properties" and give the
project a new name like MainProject). Then, in the Compliance
workbook code, use

Application.VBE.VBProjects("MainProject").VBCompon ents("ThisWorkbook").Activate


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






"DRK" wrote in message
...
I have two workbooks - I'll call them Main and Compliance.
Compliance is used
solely to print the legal compliance stuff. Main handles the
concept stuff
and printing the concept stuff.

My custom menu in Main calls a print macro in Compliance. When
that macro is
done, I want to activate the Main workbook. The problem is the
Main Workbook
name can be different so I can't hard code the name into
Compliance code to
activate the Main workbook.

The end users want to save each Main workbook under a different
name to
preserve their cases.

How can I send or carry over the name of the Main workbook with
what ever is
its current name to the Compliance workbook?

--
DRK




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 check workbook is already opened before passing the workbook obj to a subroutine in Word Bon Excel Programming 2 January 19th 06 09:54 AM
why is an Excel file called a workbook? Monique Excel Discussion (Misc queries) 3 October 14th 05 05:52 PM
Reference code in another workbook from a calling workbook Datasort Excel Programming 1 January 4th 05 01:13 AM
Worksheet_Activate Not Called When Opening Workbook Gaston Excel Programming 6 October 29th 04 09:49 PM
Worksheet_Activate Not Called When Opening Workbook Bob Phillips[_6_] Excel Programming 1 October 29th 04 12:01 AM


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