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 / August 2005

Tip: Looking for answers? Try searching our database.

Symbols & Userforms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stefan_B - 01 Jun 2005 11:09 GMT
Hi,

I'm a bit stuck at the moment with Word.  I have a userform, which I want
users to be able to input symbols onto (e.g. individual fields on the
Userform).    Unfortunately entering a symbol as ASCII code isn't going to be
possible as the symbols need to be clearly displayed for the user to choose.

Does any one have any ideas, how this can be done.

Thanks in advance.
Jonathan West - 03 Jun 2005 11:55 GMT
> Hi,
>
[quoted text clipped - 8 lines]
>
> Thanks in advance.

You can use Word's built-in Insert Symbol button. The following function
displays the Insert Symbol dialog. If the return value of the function
is -1, then the Charnum and Fontname arguments return the character number
and font name of the selected character.

Function PickSymbol(CharNum As Long, FontName As String)
Dim iDisplay As Long
With Dialogs(wdDialogInsertSymbol)
 iDisplay = .Display
 If iDisplay = -1 Then
   CharNum = .CharNum
   FontName = .Font
 End If
End With
PickSymbol = iDisplay
End Function

A bit of shell code that illustrates the use of the function is as follows

Sub ShowSymbol()
Dim strFont As String
Dim iChar As Long
If PickSymbol(iChar, strFont) = -1 Then
 Debug.Print iChar, strFont
End If
End Sub

You could call ther PickSymbol function from the Click event of a
Commandbutton. Armed with the character code and font name, it should be
quite straightforward to set the text and font of a label to reflect the
selected symbol.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Armed with the character code and font, it should be easy enough then to put
the correct

Allan - 13 Aug 2005 02:49 GMT
Good Morning,
I am trying to do the same thing. By using the following code, th
dialog window is opened with theuse of a keyboard shortcut but the
stops witht a command failed message at teh insertsymbol line. It woul
appear that the vba dialogs object doesn't recognise charnum. Ca
somebody pease assist with this problem?

Public Sub Insert_Symbol()
Dim mysymbol As String
Dim symbolnum As Long
Dim myrange As Range
Dim CurFont As String
Dim myFont As String
Dim Dlg As Object

'unlock the form
LockUnlockForm
'set dlg to symbol insertion dialog window
Set Dlg = Dialogs(wdDialogInsertSymbol)

With Dlg
If .Display = -1 Then
myFont = .Font
symbolnum = .CharNum

'relock the form if user chooses cancel
ElseIf .Display = 0 Then
LockUnlockForm
Exit Sub
End If

End With

' insert the symbol at the cursor
Set myrange = ActiveDocument.Characters(1)

With myrange
.Collapse Direction:=wdCollapseStart
.InsertSymbol CharacterNumber = symbolnum, _
Font = myFont, Unicode = True, Bias = 0
.Move Unit:=wdCharacter, Count:=1
End With

'relock the form
LockUnlockForm

End Su

--
Alla
Doug Robbins - 13 Aug 2005 06:40 GMT
In the following command, you have omitted the colons after each attribute

nsertSymbol CharacterNumber = symbolnum, _
Font = myFont, Unicode = True, Bias = 0

It should be

nsertSymbol CharacterNumber: = symbolnum, _
Font: = myFont, Unicode: = True, Bias: = 0

Another issue that you have though is ensuring that the "from:" pulldown is
set to Unicode (hex).  That can be done using:

SendKeys "%m{up}{up}~"
With Dlg
If .Display = -1 Then
myFont = .Font
symbolnum = .CharNum

Signature

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

>
> Good Morning,
[quoted text clipped - 44 lines]
>
> End Sub
Allan - 13 Aug 2005 07:30 GMT
Doug,
Thanks for the repsonse. I have placed the colonsin the code an
everything apears to work except that the symbol is still not inserted
The variables are obtaining the details from the dialog box but no
inserting them. Is the problem with the selection? After running th
code, the whole form field is selected but no symbol has bee
inserted.

Look forward to your reply

--
Alla
Doug Robbins - 13 Aug 2005 08:11 GMT
The only changes that I made to your code were the ones that I mentioned and
it works for me.

Signature

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

>
> Doug,
[quoted text clipped - 6 lines]
>
> Look forward to your reply.
Allan - 13 Aug 2005 11:32 GMT
Doug,
I appreciate that the code works, just not on my form. It goes thoug
all the motions and then selects the whole form field without placin
the symbol in it. I am using word 2003 but this template may be used o
other versions of Word.
Once again, thanks for any help with this problem

--
Alla
 
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.