Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Toolbar troubles

I have some code that creates two toolbars when a template workbook is opened.

These tools bars do various things in the workbook, and then when i close
that workbook the toolbars are deleted using the sub beforeclose. however if
i have more than one workbook open that uses the code and i close one of them,

it deletes the toolbars and i cant use them in the still open workbook. i
tried just not deleting the toolsbars at close, but they stay linked to the
workbook that created them rather than acting on the open workbook. The code
that creates them is very long, so i wont post it all but here is the
begining where some of it is created:
Private Sub Workbook_Open()
LOADING.Show vbModeless
LOADING.Repaint
Dim DScb As CommandBar
Dim add_door As CommandBarButton
Dim oak As CommandBarButton
Dim raw As CommandBarButton
Dim maple As CommandBarButton
Dim pine As CommandBarButton
Dim alder As CommandBarButton
Dim cherry As CommandBarButton
Dim hrdwToolBar As String

hrdwToolBar = "Hardware"

Set CustomToolBar = Application.CommandBars.Add(Name:=hrdwToolBar,
Position:=msoBarTop)
CustomToolBar.Visible = True

Set HARDWARE = CustomToolBar.Controls.Add(Type:=msoControlPopup)
HARDWARE.Caption = "Hardware"

Set mouldings = CustomToolBar.Controls.Add(Type:=msoControlPopup)
mouldings.Caption = "Mouldings"

Set stairparts = CustomToolBar.Controls.Add(Type:=msoControlPopup)
stairparts.Caption = "Stair Parts"

With stairparts.Controls
Set newel = .Add(Type:=msoControlPopup)
newel.Caption = "Newels"
Set balusters = .Add(Type:=msoControlPopup)
balusters.Caption = "Balusters"
Set rails = .Add(Type:=msoControlPopup)
rails.Caption = "Rails"
End With

With rails.Controls
Set sch6005 = .Add(Type:=msoControlButton)
sch6005.Caption = "SCH-6005"
End With

With sch6005
.OnAction = "rail_run"
.Tag = "sch6005"
End With

Could the problem be with how the toolbars are created? Is there a better
way to create them once not on opening of workbook, but just create them and
then they will run the appropriate macros in the activeworkbook? Any
thoughts? Sorry if this is confusing.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200705/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Toolbar troubles

hi,
the way the toolbars are created I don't think is the problem.
in your post you said that the tool bars are DELETED using the beforeclose
sub. I suspect that imay be your problem.
but i am confused. you said in your post that more than one file uses the
code and if your have 2 files open and close one the toolbars are deleted.
does that mean closing any file deletes the toolbars or just the file with
the code in it.
and if more that one file uses the toolbars, i would consider putting the
code in a personal workbook and run the code from a costom menu item or icon
as needed.
my thoughts.
Regards
FSt1

"brownti via OfficeKB.com" wrote:

I have some code that creates two toolbars when a template workbook is opened.

These tools bars do various things in the workbook, and then when i close
that workbook the toolbars are deleted using the sub beforeclose. however if
i have more than one workbook open that uses the code and i close one of them,

it deletes the toolbars and i cant use them in the still open workbook. i
tried just not deleting the toolsbars at close, but they stay linked to the
workbook that created them rather than acting on the open workbook. The code
that creates them is very long, so i wont post it all but here is the
begining where some of it is created:
Private Sub Workbook_Open()
LOADING.Show vbModeless
LOADING.Repaint
Dim DScb As CommandBar
Dim add_door As CommandBarButton
Dim oak As CommandBarButton
Dim raw As CommandBarButton
Dim maple As CommandBarButton
Dim pine As CommandBarButton
Dim alder As CommandBarButton
Dim cherry As CommandBarButton
Dim hrdwToolBar As String

hrdwToolBar = "Hardware"

Set CustomToolBar = Application.CommandBars.Add(Name:=hrdwToolBar,
Position:=msoBarTop)
CustomToolBar.Visible = True

Set HARDWARE = CustomToolBar.Controls.Add(Type:=msoControlPopup)
HARDWARE.Caption = "Hardware"

Set mouldings = CustomToolBar.Controls.Add(Type:=msoControlPopup)
mouldings.Caption = "Mouldings"

Set stairparts = CustomToolBar.Controls.Add(Type:=msoControlPopup)
stairparts.Caption = "Stair Parts"

With stairparts.Controls
Set newel = .Add(Type:=msoControlPopup)
newel.Caption = "Newels"
Set balusters = .Add(Type:=msoControlPopup)
balusters.Caption = "Balusters"
Set rails = .Add(Type:=msoControlPopup)
rails.Caption = "Rails"
End With

With rails.Controls
Set sch6005 = .Add(Type:=msoControlButton)
sch6005.Caption = "SCH-6005"
End With

With sch6005
.OnAction = "rail_run"
.Tag = "sch6005"
End With

Could the problem be with how the toolbars are created? Is there a better
way to create them once not on opening of workbook, but just create them and
then they will run the appropriate macros in the activeworkbook? Any
thoughts? Sorry if this is confusing.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200705/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Toolbar troubles

i got it to work out by using the activate and deactivate subs.


FSt1 wrote:
hi,
the way the toolbars are created I don't think is the problem.
in your post you said that the tool bars are DELETED using the beforeclose
sub. I suspect that imay be your problem.
but i am confused. you said in your post that more than one file uses the
code and if your have 2 files open and close one the toolbars are deleted.
does that mean closing any file deletes the toolbars or just the file with
the code in it.
and if more that one file uses the toolbars, i would consider putting the
code in a personal workbook and run the code from a costom menu item or icon
as needed.
my thoughts.
Regards
FSt1

I have some code that creates two toolbars when a template workbook is opened.

[quoted text clipped - 58 lines]
then they will run the appropriate macros in the activeworkbook? Any
thoughts? Sorry if this is confusing.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200705/1

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
Troubles Jonas Krogh Excel Discussion (Misc queries) 1 October 22nd 09 11:14 AM
Config Now() troubles Libbyc80 Excel Worksheet Functions 0 April 7th 08 06:34 PM
COM Add-in Troubles Howard Excel Discussion (Misc queries) 0 May 22nd 07 01:59 PM
Toolbar Troubles brownti via OfficeKB.com Excel Discussion (Misc queries) 2 May 3rd 07 10:02 PM
IF troubles JG Excel Worksheet Functions 6 December 24th 06 04:58 AM


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