QUOTES "word"

M

MJV

Office 2000. Windows 200 Pro & Windows M

I would like to develop a method to select all text and puts quotes ("word") around each word that I select

For example - Microsoft Word is better than everything else

Would become - "Microsoft" "Word" "is" "better" "than" "everything" "else"

thank
--mike
 
J

Jean-Guy Marcil

Hi there,

try this:

'_______________________________________
Sub Quote_Selected_Words()

Dim SelText As Range
Dim WordRange As Range
Dim CharCount As Long

Dim oWord As Variant

Set SelText = Selection.Range

'If selection starts with a space, the sub will
'also iclude the first word
'but it will also inlcude the first and last
'word even if they are not fully selected
If SelText.Characters(1) = " " Then
SelText.MoveStart wdCharacter, 1
End If

For Each oWord In SelText.Words
Set WordRange = oWord
'A word always include the following space,
'if there is one
CharCount = WordRange.Characters.Count
If WordRange.Characters(CharCount) = " " Then
WordRange.MoveEnd wdCharacter, -1
End If
'If the first character is a quote then it is
'either a quote we just added and that is preceding
'a punctuation mark (which are included in the Words
'collection), or it is a word already
'quoted, so no need to double quote it
If WordRange.Characters(1) = """" _
Then GoTo Skip_Quotes

WordRange.InsertBefore """"
WordRange.InsertAfter """"

Skip_Quotes:

Next oWord

End Sub
'_______________________________________

--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org


MJV said:
Office 2000. Windows 200 Pro & Windows Me

I would like to develop a method to select all text and puts quotes
("word") around each word that I select.
 
M

MJV

That worked perfect

Now that this is possible, I would like to add a "pop up" box that displays a message after all of the words have been quoted. Ideally, I would like the "pop up" box to have a picture in the background. How can I go about this

thanks
--mike
 
J

Jean-Guy Marcil

Hi Mike,

Use a userform with a label for the message, a picture and an OK button....

--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org


MJV said:
That worked perfect!

Now that this is possible, I would like to add a "pop up" box that
displays a message after all of the words have been quoted. Ideally, I
would like the "pop up" box to have a picture in the background. How can I
go about this?
 
M

MJV

Hello

I am not familiar with how to do that...can you take me through it step by step

thank
--mike
 
J

Jean-Guy Marcil

Hi Mike,

See
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm
with the following changes:

Ignore all the stuff about bookmarks (Step 2) and textboxes (The point of
that sample is to build a userform to get user input, and then place that
input in the document). You may want to try that later though, very useful
to know!

On the user form, insert a label as suggested in the tutorial, put your
message in it (Step 7).
Then, instead of inserting a textbox (Step 5), insert an image control (The
mountain with the sun).
Make sure the Property pane is displayed (Usually, under the project
explorer, on the left at the bottom, View, Property Window in from the VBA
menus).
IN the property window, with the image control selected, find the Picture
property, click on it, a button with "..." should appear on the right side,
click on that button to browse for the image you want. You may want to play
around with PictureSizeMode, PictureAlignment and PictureTiling while you
are there to get the desired look (after inserting the image).

In Step 10, use only:

UserForm1.Hide

and add

Unload UserForm1

Then Ignore Steps 11, 12 and 13.

To activate the Userform, in the code I posted before, add this just before
the "End Sub":

UserForm1.Show

Assuming that your userform is called UserForm1, which will be the default
name given by Word when your fist create it.

Good luck!
--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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