Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create a window showing building block organiser in 2007

2 views
Skip to first unread message

Peter

unread,
Nov 8, 2008, 9:31:00 PM11/8/08
to
Ideally I would like the window to be formated similiat to the autotext entry
in Word 2003 e.g. shows the list of names of the items then a preview of the
contents of the item. Ideally it would be a modeless window that could float
over the application but this is not necessary. The basic context is that I
use Word Autotext enties to insert comments into documents when making
assignments.

It works very well in Word 2003 (the autotext box allows you to easily key
through the enteries and the preview that is shown is large enough to read
the entries) but in 2007 it is not as easy to use (the names are not shown in
a list and the entries are not large enough to read). About 13 minutes into
the screeen movie at http://baker-evans.com/marker%27s-assistant/demo.html
there is a demo.

Any assistance woudl be gratefully received,
Pete Evans

Doug Robbins - Word MVP

unread,
Nov 9, 2008, 1:40:01 AM11/9/08
to
You could use a UserForm, displayed as modeless, that contains a combobox, a
multiline textbox and a command button named cmbAutotext, txtAutotextValue
and cmdInsertComment respectively and have the following code in the User
Form

Private Sub cmbAutotext_Change()
With Me.cmbAutotext
.BoundColumn = 2
Me.txtAutotextValue.Text = .Value
End With
End Sub

Private Sub cmdInsertComment_Click()
ActiveDocument.Comments.Add Range:=Selection.Range,
Text:=txtAutotextValue.Text
End Sub

Private Sub UserForm_Initialize()
For i = 1 To NormalTemplate.AutoTextEntries.Count
With NormalTemplate.AutoTextEntries(i)
Me.cmbAutotext.AddItem .Name
Me.cmbAutotext.List(Me.cmbAutotext.ListCount - 1, 1) = .Value
End With
Next i
End Sub

The Initialize statement will load the combobox with the names of the
autotext entries, when an entry is selected in the Combobox, its value will
be displayed in the textbox and clicking on the command button will insert a
comment containing the selected autotext at the location of the selection.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Peter" <Pe...@discussions.microsoft.com> wrote in message
news:08B11F64-1B6E-4214...@microsoft.com...

Peter

unread,
Nov 9, 2008, 6:03:02 AM11/9/08
to
Doug,

Thanks for your quick reply ... and I notice that you live just down the
range.

Unfortunately it has been soooo long since I did any VBA that it would take
a while for my fingers to create a UserForm and the various buttons and
fields. Would you have an example that you could send me to at least get me
started -- I can at least see what the code is doing. Will the text box that
displays the entries show the text be large enough to read or will it attempt
to do a page preview as the built in Building Block Organiser attempts to do.

Again, thanks for your help so far,
Peter Evans

Greg Maxey

unread,
Nov 9, 2008, 8:33:25 AM11/9/08
to
How long could it really take to create 1 field, 1 combobox, and 1 command
button? ;-)

You might be interested in
http://gregmaxey.mvps.org/Proofreader_Marks_AddIn.htm . It could easily be
adapted to include a supertip that included the text of the comment.
Supertips show when you mouse over the menu control.

While it would take considerable work to set up initially, you might also
employ a gallery control that shows actuall images of your intended comment
or marking.

See the Signature Gallery here:
http://gregmaxey.mvps.org/Ribbon_Gallery_Control.htm

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org

Greg Maxey

unread,
Nov 9, 2008, 8:59:24 AM11/9/08
to
Peter,

I went ahead and added the code to include supertip text to the dropdown
controls. The supertip text is the same as the predefined comment text that
appears in the userform. One thing that I like about this method is it give
you a chance to quick edit your comment before inserting it.

Please bear in mind that Proofreader Add-In is not a commerial product and
has not be extensively tested. It is simply the child of my efforts to
provide a working example of a dynamic dropdown control in the ribbon on my
website.

--

Doug Robbins - Word MVP

unread,
Nov 9, 2008, 2:20:44 PM11/9/08
to
As I have give you the code, I would suggest that it would take a lot less
time than getting to the point of the movie to which you referred.

I would suggest however that thinking about it now, the form would be easier
to use if it used a Listbox rather than a Combobox.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Peter" <Pe...@discussions.microsoft.com> wrote in message

news:49857ABB-F139-4C2D...@microsoft.com...

jec

unread,
Nov 9, 2008, 4:13:17 PM11/9/08
to
That's interesting Doug and Greg, MVP Christian Freßdorf says that Building
Blocks cannot be previewed in a modeless userform in Word 2007.

"Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org> wrote in message
news:%23EybBYj...@TK2MSFTNGP06.phx.gbl...

Jay Freedman

unread,
Nov 9, 2008, 4:59:47 PM11/9/08
to
Hi Pete,

Christian is right that the preview from the Building Blocks Organizer isn't
available in VBA/userforms, but what Doug has written doesn't display a
"preview". It displays the text of the entry, in the font used for the multiline
text box in the userform. It won't show any formatting that's included in the
entry; and if the entry contains a graphic or a field, you'll see an asterisk or
the field code, respectively. On the plus side, if the entries are all text, the
display is guaranteed to be readable.

Greg's contribution doesn't attempt to display anything except the name of the
entry (and a tooltip with an explanatory phrase) -- no preview there, either.

Programmatic access to the Building Block preview control is something we're
discussing with Microsoft as a desirable feature for the next version, but it's
not something to count on, and definitely not available now. And if it does
become available, it'll probably be the same tiny unreadable picture you've
already said you didn't like.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.

Greg Maxey

unread,
Nov 9, 2008, 7:56:17 PM11/9/08
to
Jay, Doug, Peter, jec,

I have been toying with this issue for a few hours and another option is to
use one of the custom building block galleries. The display in the gallery
control is larger (not by much) and usually readable as compared to the full
page preview in the organizer.

I have put together a Web tips page describing how the method can be
deployed:

http://gregmaxey.mvps.org/Buiild_Employ_Custom_BB_Gallery.htm

Jay Freedman wrote:
> Hi Pete,
>
> Christian is right that the preview from the Building Blocks
> Organizer isn't available in VBA/userforms, but what Doug has written
> doesn't display a "preview". It displays the text of the entry, in
> the font used for the multiline text box in the userform. It won't
> show any formatting that's included in the entry; and if the entry
> contains a graphic or a field, you'll see an asterisk or the field
> code, respectively. On the plus side, if the entries are all text,
> the display is guaranteed to be readable.
>
> Greg's contribution doesn't attempt to display anything except the
> name of the entry (and a tooltip with an explanatory phrase) -- no
> preview there, either.
>
> Programmatic access to the Building Block preview control is
> something we're discussing with Microsoft as a desirable feature for
> the next version, but it's not something to count on, and definitely
> not available now. And if it does become available, it'll probably be
> the same tiny unreadable picture you've already said you didn't like.
>
>

--

jec

unread,
Nov 9, 2008, 8:18:44 PM11/9/08
to
Yes I already do that Greg. It is just as easy to use CC Category Building
Blocks also.

"Greg Maxey" <gma...@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote in message
news:eVhtg8sQ...@TK2MSFTNGP03.phx.gbl...

Greg Maxey

unread,
Nov 9, 2008, 9:09:35 PM11/9/08
to
jec,

What is CC Category?

jec

unread,
Nov 9, 2008, 9:21:38 PM11/9/08
to
Sorry Greg,
Content Control (CC) with a Building Blocks Category list works very well in
custom templates, as does having the Gallery on the ribbon showing the
Gallery also.

"Greg Maxey" <gma...@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote in message

news:%23Cvkdlt...@TK2MSFTNGP04.phx.gbl...

Peter

unread,
Jan 6, 2009, 2:46:01 AM1/6/09
to
Gary,

You are right, it was not that difficult once I had some time to sit down
and look at it.

I now have the UserForm, displayed as modeless, that contains a listbox, a

multiline textbox and a command button named

cmbAutotext, txtAutotextValue and cmdInsertComment respectively and the code
you provided.

I scroll through the listbox or use the arrow keys and the text of the
highlighted autotext item is displayed in the textbox all in a modeless
UserForm.

The question is that I like the list box to automatically scroll if the user
clicks it then starts to type characters e.g. if the autotext names are fred,
jane, joan and sue then the user typed J then Jane would be highlighted and
as soon as they pressed O then joan would be highlighted.

How do I get this type of behaviour?

As you probably guessed I am new to all of this.

Peter


> How long could it really take to create 1 field, 1 combobox, and 1 command
> button? ;-)

{snipped}

Doug Robbins - Word MVP

unread,
Jan 6, 2009, 6:52:48 PM1/6/09
to

I assume that you mean a combobox as I had suggested, and not a ListBox. To
get the selection to go to the item that you start typing, set the
MatchEntry attribute of the ComboBox to

0 - fmMatchEntryFirstLetter

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Peter" <Pe...@discussions.microsoft.com> wrote in message

news:B7B64888-5BF0-4715...@microsoft.com...

Peter

unread,
Jan 12, 2009, 9:47:01 PM1/12/09
to
Fantastic ... works just as you said.

And even better if I set "Match Entry" to "1 -fmMatchEntryComplete" it will
allow me to type enough letters to make the item unique and scroll to that
item.

Peter Evans

Peter

unread,
Jan 12, 2009, 10:04:00 PM1/12/09
to
Greg and Doug (and others)

Thanks to your help so far. I can now scroll through the combolist (or type
the first couple of characters) to find the name of the autotext entry and
then click the the INSERT AS TEXT" button to insert it into the doucment or
another button to insert it as a comment. This is Good.

BUT if the autext entry contains an image the inserted item contains
something like "* EMBED Equation.DSMT4 **" and not the image. If I insert it
using INSERT > AUTOTEXT then the original with the image is inserted.

I have been using
ActiveDocument.Comments.Add Range:=Selection.Range,
_Text:=txtAutotextValue.Text

or even the following to try to get the complete value of autotext item 87

Selection.InsertAfter NormalTemplate.AutoTextEntries(87)

But all I get entered is the text of the item and not the complete item.
How can I insert the real item?

The reason that I am using my own button to insert the item is that I also
want to add other items to the comment or the text.

Greg Maxey

unread,
Jan 14, 2009, 9:14:12 AM1/14/09
to
Peter,

You insert an autotext entry like this:

NormalTemplate.AutoTextEntries(87).Insert Selection.Range, True

You CAN'T insert a drawing object in a comment. The following example
illustrates:

Sub Test()
Dim oRng As Word.Range
Dim oCom As Comment
Set oCom = ActiveDocument.Comments.Add(Range:=Selection.Range, Text:="")
NormalTemplate.AutoTextEntries("87").Insert oCom.Range, True
End Sub

Peter

unread,
Jan 15, 2009, 1:41:01 AM1/15/09
to
Thanks Greg ... another step closer

And even better I have found out that while
NormalTemplate.AutoTextEntries(autoTextItemNum).Add oCom.Range, True

is not supported

NormalTemplate.AutoTextEntries(autoTextItemNum).Insert oCom.Range, True

is Ok and it allows you to insert an autotext entry containing a drawing
into a comment under VBA in the same way you can if you are using the
keyboard.

Peter

0 new messages