Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ON OPEN VBA Code input incorrectly now excel sheet wont open | New Users to Excel | |||
Can't get bar code font to work in EXCEL 2003 | Excel Discussion (Misc queries) | |||
in Excel how do you set a workbook to only open on the first work. | Excel Discussion (Misc queries) | |||
Office C# code behin : CommandBar Class Problem ? | Excel Programming | |||
Create CommandBar in xl95 code - possible? | Excel Programming |