HELP!!!!! -- Custom toolbar

X

XmlAdoNewbie

Hi All,
I have a word template that opens to a form in which the user can
select a word document and open it for edit. This all works pretty
good, it starts to act a bit *WONKY* when i try and add my own custom
tool bar, What i want to be able to do is open the word document
WITHOUT ANY MENU's and just have my own menu that will have save,
close, bullets, font size, italics and bold but that's it. I can open
the word document without any menu's however when i try and add my
custom menu a few things happen that are unexpected.

1) my tool bar does not show up, but if i try and open it under the
"view" menu option i can see it in the list of toolbars.

2) when i try and close the application i get the error "This file is
in use by another application or user (C:\\.....normal.dot). so then i
say ok to this dialog and another dialog comes up and says "Changes
have been made that affect the global template. Do you want to save
those changes?" and i say cancel and it will close properly..

Here is my code


Private Sub cmdEdit_Click()

Dim newCommandBar As CommandBar
Dim newCommandBarControl As CommandBarControl

Set docApp = New Word.Application

With docApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With

docApp.CommandBars("Menu Bar").Enabled = True
docApp.CommandBars("Formatting").Visible = False
docApp.CommandBars("Standard").Visible = False

Set newCommandBar = docApp.CommandBars.Add("Doclet Editor",
msoBarFloating, , True)
Set newCommandBarControl = newCommandBar.Controls.Add

With newCommandBarControl
.Caption = "Save"
.Visible = True
End With


ActiveDocument.ActiveWindow = docApp.Documents.Open(docletPath &
Me.txtSource)
'Me.txtSource is the path to the document i want to open.

End Sub

Any ideas??
 
M

murdoch

Hi

2 thoughts. First, you need to set the commandbar visible
yourself (newCommandBar.Visible = True). Second, it looks
like even creating a temporary bar is making a change to
the normal template, hence the prompt you're getting. As
your code is in a template, maybe you could put the
commandbar in there too manually at design time? (in Word,
not the IDE: View, Toolbars, Customize)

HTH


-----Original Message-----
Hi All,
I have a word template that opens to a form in which the user can
select a word document and open it for edit. This all works pretty
good, it starts to act a bit *WONKY* when i try and add my own custom
tool bar, What i want to be able to do is open the word document
WITHOUT ANY MENU's and just have my own menu that will have save,
close, bullets, font size, italics and bold but that's it. I can open
the word document without any menu's however when i try and add my
custom menu a few things happen that are unexpected.

1) my tool bar does not show up, but if i try and open it under the
"view" menu option i can see it in the list of toolbars.

2) when i try and close the application i get the error "This file is
in use by another application or user
(C:\\.....normal.dot). so then i
 
X

XmlAdoNewbie

Hi Murdoch,
Thanks for your response!! The thing about putting the toolbar
manually into word is this.. I have a folder of about 99 word
documents that the user can choose from to edit, if i create the
toolbar manually do i attach it to normal.dot or what do i attach it
to because i open these word documents as themselves not into another
template?? And if i do attach it to normal.dot when i go to distribute
this application do i have to manually go into every computer the
application sits on and create the toolbar for each user??

I could create another template and open each document into that
template the thing with that is when the user presses save it saves
the template not the actual document they have opened... does that
mean i would have to create my own save function?? and if so is that
easy enough to do??

Thanks
Erin
 
M

murdoch

Hi
I'd put the code and the toolbar in a template and then
place the template in each user's Word "Startup" folder as
shown in Word, Tools, Options, File Locations. The toolbar
will then be visible every time they open Word and the
code you write will also be usable without them doing
anything special. Putting such stuff in the Normal
template is OK except that every so often Word trashes it
and creates a nice shiny new (but totally empty) one all
by itself! Bear in mind that the second time you install
(i.e. update) any template which Word loads when it
starts, Word needs to be shut. If all users share the same
Startup folder, they ALL have to close Word. So there
might be advantages in not doing it this way.

If you want it only to be available for particular docs
and not for others it gets a little more complicated.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top