PDA

View Full Version : Solved: Change Font Name & Size For Bookmark Text



CreganTur
06-18-2008, 11:48 AM
I'm working on automating a form letter that uses the Wingdings font empty checkbox (chr #168) and selected checkbox(chr #253) characters as a part of the letter's text. The user's selections on the doc's UserForm will decide which of these 2 characters will be inserted at specified bookmarks.

This is the method I tried using to insert the selected checkbox (chr #253) in a test document:
ActiveDocument.Bookmarks("CheckedBox").Select
Selection.Font.Name = "wingdings"
Selection.Font.Size = 16
Selection.Text = Chr(253)

This code works sporadically in the actual letter, but I can't get it to work consistently. But, when I created a test document, I can't get it to work at all. I'm currently blinded by my n00b glasses, and can't see what the answer is.

I've attached an example spreadsheet that tries to use the direct method above, along with a second method that created an update Sub so I just have to pass parameters to it from my button_click event. Neither one works.

NinjaEdithttp://img293.imageshack.us/img293/9060/ninja3od8.gif: Alt + 6 is the hotkey for making the UserForm appear in the attached doc.

MOS MASTER
06-18-2008, 12:24 PM
Hi,

In this document I can't see the code you posted above and therefore not see what the problem is or think about the correct behaviour. (This looks like the same attachment you posted in the question from yesterday... I'm interested too if you liked the sollution to that question)

Could you post the correct attachment?

CreganTur
06-18-2008, 12:56 PM
(This looks like the same attachment you posted in the question from yesterday

That's strange... I just opened that attachment and it's the correct one...:think:



... I'm interested too if you liked the sollution to that question)

Haven't had the time to try it out. I've been hit by the Wednesday from hell today:devil:

As soon as I get a chance I'll try out your suggestion and let you know.

Can't wait for quitting time today so i can get out of herehttp://img293.imageshack.us/img293/9060/ninja3od8.gif

MOS MASTER
06-18-2008, 01:03 PM
Hi, :yes

You are right your old file was still on my desktop and also had the name checkbox in it so I'd made a mistake.

I'll look at the document now.

MOS MASTER
06-18-2008, 01:17 PM
Hi, :yes

If I read your question correct your problem is that the symbols don't appear correct yes?

Inserting symbols is always difficult because you need to take codepaging in consideration as well.

I usually misuse the Symbol dialog to my advantage by creating a method that executes that dialog like:

Sub test()
InsertSymbol 168
End Sub

Sub InsertSymbol(iNr As Integer)
With Dialogs(wdDialogInsertSymbol)
.Font = "Wingdings"
.CharNum = iNr
.Execute
End With
End Sub

This way the dialog is responsible for inserting the item and it can do a better job then us. ;)

I'm sure you can fit this into your code.

HTH :whistle:

fumei
06-18-2008, 01:34 PM
Interesting. I have been at this for almost an hour so far.

Hmmmmm.

I can easily put WingDings Chr(253) and Chr(168) at any Selection point...but NOT at a bookmark.

So far.

Interesting. I did have it working...and then...it didn't work.

What the heck????!!!!

CreganTur
06-18-2008, 01:52 PM
This way the dialog is responsible for inserting the item and it can do a better job then us

Interesting... I'll try that tomorrow.


Interesting. I did have it working...and then...it didn't work.

What the heck????!!!!
That's what I'm saying!!!:bug:

It worked perfectly in my first test. Then I used the exact same code later that day (after adding it into the rest of the procedure) and it stopped working. I'm glad I'm not the only one experiencing this.

fumei
06-18-2008, 02:08 PM
Not only that, but I can use it at a bookmark...then...it won't.

Hmmmm.

fumei
06-18-2008, 02:09 PM
Oh, and I have much better luck using Chr(111) rather than Chr(168).

MOS MASTER
06-18-2008, 02:09 PM
Guys, :yes

Word is different (as Steve would put it) so please have a beer and use the Word tool to do it! ;)

fumei
06-18-2008, 02:11 PM
Huh? I am using Word. The whole application is a tool. So is VBA.

Oh and Randy, I pretty much have it working using Text = CStr(Chr(253)).

MOS MASTER
06-18-2008, 02:21 PM
Gerry, I meant the Symbol dialog tool sollution ofcourse. ;) (I've been fighting with symbols in the past as well)

But I know you like strange things so have a good one.

CreganTur
06-19-2008, 05:58 AM
It took me a while, but I finally got Moose's solution to work with with my bookmarks.

I've attached a solved version of the problem spreadsheet that shows the solution in action.

Private Sub btnTest1_Click()
ActiveDocument.Bookmarks("CheckedBox").Select
Selection.Font.Size = 16
Selection.Text = InsertSymbol(253)
ActiveDocument.Bookmarks("EmptyBox").Select
Selection.Font.Size = 16
Selection.Text = InsertSymbol(168)
Unload Me
End Sub

Function InsertSymbol(iNr As Integer)
With Dialogs(wdDialogInsertSymbol)
.Font = "Wingdings"
.CharNum = iNr
.Execute
End With
End Function