Repost (Urgent): Customizing Menus and Toolbars in InfoPath 2003

  • Thread starter Francesc Blanes
  • Start date
S

Scott L. Heim [MSFT]

Hi,

Here are sample steps that I just completed that appear to work - let me
know if you do not get the same results:

- Create a new, blank InfoPath form
- From the Tools menu, choose Customize
- Select the Toolbars tab
- Click the New button and enter: TestCBar as the name
- Select the Commands tab
- Select the Insert Category
- Drag the Clip Art Command to TestCBar
- Click Close
- Add a button to the form
- Add the following code to the Click event of the button:

Dim objCommandBars
Dim objControl
Stop
Set objCommandBars = Application.ActiveWindow.CommandBars

Set objControl = objCommandBars("TestCBar").FindControl(1, 682)
XDocument.UI.Alert objControl.Caption

- Make your form fully trusted
- Test

When I test this code, I get a message box with the caption: Clip Art. If I
then add another button to the toolbar and modify the code to reflect that
controls "ID", I correctly get that caption as well.

Let me know if I am doing something different.

Thanks!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
F

Francesc Blanes

Hello,

First of all, thank you for your answers!!

I'm trying to create a custom toolbar that should be part of my form
template. But.. I'm want to mix custom control with default buttons. For
this reason I want to "copy" default buttons to an custom toolbar that I will
create in the xsf file.

I've been able to reproduce the Scott's example but it doesn't work for
controls like 340 - &Highlight (Yellow) -. Finally I've found a workaround
with next code:

Dim objCommandBars
Dim objControl
Set objCommandBars = Application.ActiveWindow.CommandBars
Set objControl = objCommandBars("TestCBar").FindControl(1, 340)
Set objControl = objCommandBars("TestCBar").Controls(1)

Anyway this doesn´t solve my real problem. I'm want the objControl to use it
in a custom button in this way "objControl.Control.Execute()", but next code
Dim objCommandBars
Dim objControl
Set objCommandBars = Application.ActiveWindow.CommandBars
Set objControl = objCommandBars("TestCBar").FindControl(1, 340)
objControl.Control.Execute()
just open the tool to select a background color instead of applying the
background style to the selected text.

My problem is that I want to apply my own format to the selected text in a
rich text box. And... being able to reset the format - like using
font->remove format in the task panel - too. (I need to mark part of the text
to apply a personalized style when it will be converted to HTML). I think
that this is very easy with other Office tools like Word , but I didn't found
how to do it with Infopath.

Any help?

Thanks a lot!!

Francesc Blanes

Greg Collins said:
Francesc,

Are you looking to create a permenant application tooblar on your own machine, or a custom toolbar that is part of your form template?

The link you originally posted indicates a form toolbar... the instructions Scott provides work, but create a machine dependent application toolbar that is not part of the form.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi,

Here are sample steps that I just completed that appear to work - let me
know if you do not get the same results:

- Create a new, blank InfoPath form
- From the Tools menu, choose Customize
- Select the Toolbars tab
- Click the New button and enter: TestCBar as the name
- Select the Commands tab
- Select the Insert Category
- Drag the Clip Art Command to TestCBar
- Click Close
- Add a button to the form
- Add the following code to the Click event of the button:

Dim objCommandBars
Dim objControl
Stop
Set objCommandBars = Application.ActiveWindow.CommandBars

Set objControl = objCommandBars("TestCBar").FindControl(1, 682)
XDocument.UI.Alert objControl.Caption

- Make your form fully trusted
- Test

When I test this code, I get a message box with the caption: Clip Art. If I
then add another button to the toolbar and modify the code to reflect that
controls "ID", I correctly get that caption as well.

Let me know if I am doing something different.

Thanks!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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