Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandBar code does NOT work if Excel is Already Open :(

Hi Everyone
I am having a problem getting my CommandBar code working when there i
already an Excel Application running.

When I run my program and there are no other Excel processes running
my Tool Bar changes display properly (I am hiding the Save and Ne
buttons on the toolbar).

But - when I already have an Excel application up, then when I run th
application - it looks like it is using the Tool Bar from the existin
Excel and my Save and New buttons reappear :(

Is there anyway to fix this?

Thanks so much in advance.
Staci

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandBar code does NOT work if Excel is Already Open :(

Stacie,

You need to put some code in the ThisWorkbook object of you
spreadsheet that amends the toolbar.

The two events you need to look a

Workbook_Activate

and

Workbook_Deactivate

In _Activate you place some code (or a call to a sub) to amend th
toolbar as required. In _Deactivate you place code (or a call to
different sub) to return the toolbar to its default state.

Where have you placed the code that amends the toolbar currently?

TheDuc

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandBar code does NOT work if Excel is Already Open :(

Hi.
Here is the code that I am using:

theWorksheet.Activate();

ToolBar = ExcelApp.CommandBars["Standard"];
ToolBar.Controls["Save"].Visible = false;
ToolBar.Controls["Open"].Visible = false;
ToolBar.Controls["New"].Visible = false;

theWorksheet.Deactivate();


If Excel is already running on my machine - then the Save/New and Open
buttons are STILL visible.

If Excel is not already running - then the buttons are gone.

I am not sure how to solve this problem....


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default CommandBar code does NOT work if Excel is Already Open :(

How do you assign the Excel application to the ExcelApp object variable?
If Excel is already open, you need to use GetObject to find the existing
instance.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

sbriscoe < wrote:

Hi.
Here is the code that I am using:

theWorksheet.Activate();

ToolBar = ExcelApp.CommandBars["Standard"];
ToolBar.Controls["Save"].Visible = false;
ToolBar.Controls["Open"].Visible = false;
ToolBar.Controls["New"].Visible = false;

theWorksheet.Deactivate();


If Excel is already running on my machine - then the Save/New and Open
buttons are STILL visible.

If Excel is not already running - then the buttons are gone.

I am not sure how to solve this problem....


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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandBar code does NOT work if Excel is Already Open :(

Hi
I am just creating a new instance of the Excel application to use...

ExcelApp = new Excel.Application();

How would I get reference to the current Excel application in C#

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default CommandBar code does NOT work if Excel is Already Open :(

How come everyone's asking about C# these days? I don't know how to use
C#, but I'll tell you the VB/VBA way, and hopefully you can figure out
how to use it.

Creating a new Excel instance is done this way:

Set ExcelApp = CreateObject("Excel.Application")

Accessing the currently open Excel instance is done similarly:

Set ExcelApp = GetObject(,"Excel.Application")

If there are multiple instances, I don't know how to specify which one
to use.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

sbriscoe < wrote:

Hi
I am just creating a new instance of the Excel application to use...

ExcelApp = new Excel.Application();

How would I get reference to the current Excel application in C#?


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


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
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
Can't get bar code font to work in EXCEL 2003 Tony Excel Discussion (Misc queries) 3 December 5th 09 06:19 PM
in Excel how do you set a workbook to only open on the first work. Mark_J Excel Discussion (Misc queries) 9 February 1st 07 10:07 PM
Office C# code behin : CommandBar Class Problem ? cybertof Excel Programming 1 February 23rd 04 01:04 AM
Create CommandBar in xl95 code - possible? jamieuk Excel Programming 5 February 9th 04 02:23 PM


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