Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Unexpected hide of toolbars

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephan - 28 Feb 2005 08:23 GMT
On open time in the autoOpen Macro I create some toolbars. The toolbars are
visibel until the end of the autoOpen Macro but then the toolbars where hide
by some one.
If I debug the autoOpen macro the toolbars don't hide. So in the real
application word maks somthing after the call of autoOpen.

What should I do to keep the toolbars visible.
Jean-Guy Marcil - 01 Mar 2005 14:44 GMT
Stephan was telling us:
Stephan nous racontait que :

> On open time in the autoOpen Macro I create some toolbars. The
> toolbars are visibel until the end of the autoOpen Macro but then the
[quoted text clipped - 3 lines]
>
> What should I do to keep the toolbars visible.

Word does not hide toolbar for no reasons. Since you are programmatically
creating the toolbar when the document opens, there is something in you code
that is not right.

Make sure you specify that the toolbar must be visible in the code and also,
it might help, check the CustomizationContext property.

If none of this help, then post back with your code. If your code is not too
long and easy to read, maybe someone will have the time to debug it for you,
unless something obvious is missing... then you will get a quick reply.
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Stephan - 02 Mar 2005 07:11 GMT
I have reduce the code to the minimum. With this code I have the same
problem. If I open this document the toolbars hide.
NOTE: The macro is defined in a Templat and not in the document itself.

sinceraly
Stephan

Code -----------------------------------------
Option Explicit

'----------------------------------------------------------------------------------'
Private Sub Ftest()
'----------------------------------------------------------------------------------'
'----------------------------------------------------------------------------------'
   MsgBox "Ftest"
End Sub

'----------------------------------------------------------------------------------'
Private Sub makeToolBarEntry(Bar As CommandBar, ID As Long, entryType,
faceId As Long, tag As String, cap As String, group As Boolean, action As
String, Optional width As Long = 0, Optional visible As Boolean = True,
Optional enable As Boolean = True)
'----------------------------------------------------------------------------------'
' Description:  This Procedure adds a control to the given tool bar.
'               if a control with the same id exists this control will be
deleted.
' Input:        Bar         the command bar to add the control
'               ID          the id  of the control
'               entryType   the type of the control ()
'               faceId      the id of the icon
'               tag         the tag text
'               cap         the caption text
'               group       insert a group delimiter
'               action      the function name of the function to be called
on selection
'               width       the size (distance) of the control
'               visible     is the control visible
'               enable      is the control enabel
' Return:       None
'----------------------------------------------------------------------------------'
Dim c As Control
On Error Resume Next
c = 0
c = Bar.Controls(ID)
If c <> 0 Then
   Bar.Controls(ID).Delete
End If

Bar.Controls.Add Type:=entryType
Bar.Controls(ID).faceId = faceId
Bar.Controls(ID).tag = tag
Bar.Controls(ID).Caption = cap
Bar.Controls(ID).BeginGroup = group
Bar.Controls(ID).OnAction = action
Bar.Controls(ID).Enabled = enable
If width > 0 Then
   Bar.Controls(ID).width = width
End If
Bar.Controls(ID).visible = visible
End Sub

'----------------------------------------------------------------------------------'
Private Sub createTestBar()
'----------------------------------------------------------------------------------'
' Description:  This Procedure creates a test toolbar. Before the toolbar is
created
'               if a toolbar with the same name exists this toolbar will be
deleted.
' Input:        None
' Return:       None
'----------------------------------------------------------------------------------'
   
   
   Dim toolBar As CommandBar
   
   CustomizationContext = Documents(ActiveDocument)
   
   On Error Resume Next
   ' remove old toolbar
   Set toolBar = Nothing
   Set toolBar = Word.ActiveDocument.CommandBars("Test Bar")
   If Not toolBar Is Nothing Then
       toolBar.Delete
   End If
   Set toolBar = Nothing
   Set toolBar = Word.CommandBars("Test Bar")
   If Not toolBar Is Nothing Then
       toolBar.Delete
   End If
   
   Set toolBar = Word.ActiveDocument.CommandBars.Add("Test Bar")
   toolBar.visible = True
   makeToolBarEntry toolBar, 1, msoControlButton, 233, "", "", True,
"Ftest", 35
   makeToolBarEntry toolBar, 2, msoControlButton, 215, "", "", False,
"Ftest", 35
   makeToolBarEntry toolBar, 3, msoControlButton, 454, "", "", False,
"Ftest", 35
   makeToolBarEntry toolBar, 4, msoControlButton, 366, "", "", False,
"Ftest", 35
   makeToolBarEntry toolBar, 5, msoControlButton, 357, "", "", False,
"Ftest", 35
   makeToolBarEntry toolBar, 6, msoControlButton, 49, "", "", True,
"Ftest", 35
End Sub

'----------------------------------------------------------------------------------'
Public Sub createBars()
'----------------------------------------------------------------------------------'
' Description:  This Procedure creates all needed tool bars.
' Input:        None
' Return:       None
'----------------------------------------------------------------------------------'
   createTestBar
   
   ' ... and more toolbars
   ' ...
   
End Sub

'----------------------------------------------------------------------------------'
Public Sub autoOpen()
'----------------------------------------------------------------------------------'
'----------------------------------------------------------------------------------'
   createBars
End Sub

> Stephan was telling us:
> Stephan nous racontait que :
[quoted text clipped - 17 lines]
> long and easy to read, maybe someone will have the time to debug it for you,
> unless something obvious is missing... then you will get a quick reply.
Christian =?iso-8859-1?Q?Fre=DFdorf?= - 02 Mar 2005 07:41 GMT
Hi Stephan,

> On open time in the autoOpen Macro I create some toolbars. The toolbars are
> visibel until the end of the autoOpen Macro but then the toolbars where hide
> by some one.

i often heared about this and experience this here with installed addins
from
Adobe Acrobat 6 (5 works fine)
Duden Korrektor 3

one solution that often works is to set the RowIndex of your Toolbar to the
last one
Commandbars("Yours").RowIndex = msoBarRowLast
there is also no difference to protect the Toolbar with
"msoBarNoChangeVisible" :(

but that's only a mostly working solution, and i don't know why and what
the addins gets up to the toolbars :(

Signature

regards Christian - MVP WordVBA
~~~~~~~~~~~~~~~~
reply only to this newsgroup
http://www.mvps.org/word/FindHelp/Posting.htm

Stephan - 02 Mar 2005 08:15 GMT
The rowIndex doesn't solve the problem. I also tried to set the
toolbar.Context to the active document with no success.
If I remove the CustomizationContext = Documents(ActiveDocument) it will be
opened but it is attached to word and not to the document. But the toolbar
should be atteched to the activedocument.

I still hope for help

Stephan

> On open time in the autoOpen Macro I create some toolbars. The toolbars are
> visibel until the end of the autoOpen Macro but then the toolbars where hide
[quoted text clipped - 3 lines]
>
> What should I do to keep the toolbars visible.
Jean-Guy Marcil - 02 Mar 2005 08:47 GMT
Stephan was telling us:
Stephan nous racontait que :

> The rowIndex doesn't solve the problem. I also tried to set the
> toolbar.Context to the active document with no success.
> If I remove the CustomizationContext = Documents(ActiveDocument) it
> will be opened but it is attached to word and not to the document.
> But the toolbar should be atteched to the activedocument.

The few times I played around with toolbars attached to documents, I found
the whole thing quite dodgy and unreliable. So I never really use them like
that. Hopefully someone with more experience in this particular area will be
along shortly!

Why must the toolbar be attached to the document?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Stephan - 02 Mar 2005 09:59 GMT
Becaause in the toolbar are real lsit boxes with contents loded for the
specific document. In the example I removed them. Because it is not relevant
for the problem.

> Stephan was telling us:
> Stephan nous racontait que :
[quoted text clipped - 11 lines]
>
> Why must the toolbar be attached to the document?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.