help need to create a macro

T

Thejan Mendis

hi this is a question I asked from several ppl but end up with empty hands.

1/ I need to convert all the text into a ms word title case type by clicking
on a button
2/ how to I break text box characters to lines which is not exceed 70
characheters per line. this is critical
b'coz it should not break middle of the words in any case.
3/ how do I change character to uppercase which I selected in a textbox


Pls anser me step by step..........

TJ
 
M

Malcolm Smith

Can you please use proper words such as 'people' and 'because' otherwise
we will get the impression that if you're too lazy to type these words out
then, perhaps, you're too lazy to work this out for yourself.


May we see how far you have got with these problems? Can we see your code
to date so that we can help you?

- Malc
www.dragondrop.com
 
T

Thejan Mendis

Hi Mark,

I tried your this one early but did not work. actually this is what I want
to I need to create a function that will process the below function as I
described in early. could you help me on this please.


THEJAN


Basically you need to assign the first 70 characters of the
paragraph, plus one, to a string variable, then check to see
if that extra character (the 71st character) is a space or
paragraph mark, and if it isn't, truncate it by looking
backward for a space, using the InStrRev function (same as
InStr except it searches from the end of the string):

Dim s As String
s = "I said this years ago and I see no reason to [...etc....]"
' --- or more likely something like:
' --- s = sourcedoc.Paragraphs(x).Range.Text

If Len(s) > 70 Then
If Mid$(s, 71, 1) = " " Or Mid$(s, 71, 1) = vbCr Then
s = Mid$(s, 1, 70)
Else
s = Mid$(s, 1, 70)
s = Mid$(s, 1, InStrRev(s, " ") - 1)
End If
End If

--
Mark Tangard <[email protected]>, Microsoft Word MVP
Please reply only to the newsgroup, not by private mail.
Note well: MVPs do not work for Microsoft.
"Life is nothing if you're not obsessed." --John Waters
 
M

Malcolm Smith

Can you show us the code which you have attempted so far so that we can
guide you a little?

Is this a requirement from your boss?

- Malc
 
T

Thejan Mendis

Hi,

No I am doing this along for one of my project.

here is the code which I assign for a USER forms and need that special
function to be execute on TEXT Object. Which is the main text box in this
form.


-------------




Private Sub btlcase_Click()

TEXT.SelText = Lcase(TEXT.SelText)
QUOT.SelText = Lcase(QUOT.SelText)
PICT.SelText = Lcase(PICT.SelText)

End Sub

Private Sub btucase_Click()

TEXT.SelText = Ucase(TEXT.SelText)
QUOT.SelText = Ucase(QUOT.SelText)
PICT.SelText = Ucase(PICT.SelText)

End Sub

Private Sub CommandButton2_Click()
End
End Sub

Private Sub CommandButton3_Click()
Dim spub As String

spub = ***
With ActiveDocument
.Bookmarks("PUBL").Range.InsertBefore ("***")
.Bookmarks("TDATE").Range.InsertBefore ("***")
.Bookmarks("ISSU").Range.InsertBefore ("***")
.Bookmarks("PAGE").Range.InsertBefore PAGE.TEXT
.Bookmarks("SECT").Range.InsertBefore SECT.TEXT
.Bookmarks("NAME").Range.InsertBefore TNAME.TEXT
****?????????? .Bookmarks("TTEXT").Range.InsertBefore
TEXT.TEXT????????********
.Bookmarks("QUOT").Range.InsertAfter ("-QUOT" & vbCr & vbCr & QUOT.TEXT)
End With
UserForm1.Hide

End Sub

Private Sub HEAD_Change()

End Sub

Private Sub Label13_Click()

MsgBox "****", vbOKOnly

End Sub
 

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