PDA

View Full Version : Insert Formatted Text



batosai17
05-08-2007, 12:39 AM
guyz, please help me..hoho.. vba word..

this is my coding:

Private Sub myCleverRemarks_Click()
Dim detail
Dim companyName
Dim companyNameRange As Range

Select Case myCleverRemarks.Value
Case "Orthopadie & Unfallchirurgie"
companyName = "Orthopadie & Unfallchirurgie :"
detail = _
companyName + vbCrLf + vbCrLf + _
" Chefarzt: Dr. Med. Th. Schockenhoff " + vbCrLf + _
" Sekretariat: Frau Hoffmeier " + vbCrLf + _
" Telefon 0 000000" + vbCrLf + _
" Telefax 0 11111111"
Case "Fachbereich Innere Medizin"
companyName = "Fachbereich Innere Medizin :"
detail = _
companyName + vbCrLf + vbCrLf + _
" Chefarzt: Prof. Dr. med. H. R. Ochs " + vbCrLf + _
" Sekretariat: Frau Titze/ Frau Passarge/ Frau Meise " + vbCrLf + _
" Telefon 0 1111111 " + vbCrLf + _
" Telefax 0 111111111 " + vbCrLf + _
" eMail test (innere@mkh-soest.de) "
Case "Kardiologie, Angiologie, Diabetologie :"
companyName = "Kardiologie, Angiologie, Diabetologie"
detail = _
companyName + vbCrLf + vbCrLf + _
" Chefarzt: Prof. Dr. med. H. R. Ochs " + vbCrLf + _
" Telefon 0111111111" + vbCrLf + _
" Telefax 0 11111111111 "
Case Else
test = _
"Unknown"
End Select

selection.Text = detail

Set companyNameRange = selection.Range
companyNameRange.Find.Execute FindText:=companyName, Forward:=True
If companyNameRange.Find.Found = True Then
companyNameRange.Bold =True
companyNameRange.Font.Size = 10
companyNameRange.Font.Name = "Arial"
End If

frmRemarks.Hide
End Sub

but how to make the companyName = "Orthopadie & Unfallchirurgie :"
is bold and the other :
" Chefarzt: Dr. Med. Th. Schockenhoff " + vbCrLf + _
" Sekretariat: Frau Hoffmeier " + vbCrLf + _
" Telefon 0 1111111111111" + vbCrLf + _
" Telefax 0 11111111111111 "

is not bold..

so, this is the value of combobox.. so, if i choose the one of the company name, it will be show in word like this:

( example i choose the second )
so the final like this :

Fachbereich Innere Medizin :

Chefarzt: Prof. Dr. med. H. R. Ochs
Sekretariat: Frau Titze/ Frau Passarge/ Frau Meise
Telefon 011111111
Telefax 0 111111111
eMail jsjasa (innere@mkh-soest.de)

but this is all bold, i just want like this :
Fachbereich Innere Medizin :

Chefarzt: Prof. Dr. med. H. R. Ochs
Sekretariat: Frau Titze/ Frau Passarge/ Frau Meise
Telefon 0 111111111111111
Telefax 011111111111
eMail ddasafsdsa (innere@mkh-soest.de)

i already search in internet, but i can't solve this problem.. anyone know the solution? please help me.. thanx..

Edited 9-May-07 by geekgirlau. Reason: Change to descriptive title

shasur
05-08-2007, 01:39 AM
Replace


Set companyNameRange = Selection.Range
companyNameRange.Find.Execute FindText:=companyName, Forward:=True
If companyNameRange.Find.Found = True Then
companyNameRange.Bold = True
companyNameRange.Font.Size = 10
companyNameRange.Font.Name = "Arial"
End If


with

Selection.Find.Execute FindText:=companyName, Forward:=True
If Selection.Find.Found = True Then
Selection.Font.Bold = True
Selection.Font.Size = 10
Selection.Font.Name = "Arial"
End If


hope it works

batosai17
05-08-2007, 01:50 AM
thanx for your help.. but, it's still not work..
hm..

mdmackillop
05-08-2007, 04:45 AM
Hi Batosai,
It is best not to publish real emails and phone numbers in your posts. Can you edit to remove these?

Charlize
05-08-2007, 05:31 AM
Try this document.

Charlize

shasur
05-08-2007, 05:38 AM
'I am not sure if there is some problem with wildcards. IF it is you can overcome by
Selection.Find.MatchWildcards = False
'Else the following should move back to your initial position and start fresh again. Check if it words atlease
Selection.Bookmarks.Add "MyTempBkMK"
Selection.Text = detail

Selection.GoTo what:=wdGoToBookmark, Name:="MyTempBkMK"
Set companyNameRange = Selection.Range
companyNameRange.Find.Execute FindText:=companyName, Forward:=True
If companyNameRange.Find.Found = True Then
companyNameRange.Bold = True
companyNameRange.Font.Size = 10
companyNameRange.Font.Name = "Arial"
End If

batosai17
05-08-2007, 05:56 AM
wow.. Charlize, thanx for your help..

thanx mdmackillop, i forget to not publish the tlp number and the emaill.. i already change it..

and Shasur, thanx for your helping me.. i wil try the best way for my VBA.. thanx all..hehe..

geekgirlau
05-09-2007, 12:52 AM
Just a note for next time - make sure the title of your post gives some idea of the problem. You tend to get more responses this way rather than using a generic "help" title.

Oh, and welcome to the Board :hi:

batosai17
05-09-2007, 02:02 AM
ok. thanx. =p