473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A Macro to select every 3rd word after selection

Hi
I need a code for a macro to select every 3rd word after selection.
Jun 28 '10 #1
7 3514
ADezii
8,834 Expert 8TB
@alphanj
Have no idea as to what you are requesting, kindly be more specific, and post concrete examples.
Jun 28 '10 #2
colintis
255 100+
So you want something like this?

Input:
I am human I am human I am human

Output:
human human human
Jun 28 '10 #3
@colintis
@colintis
some thing like that, but without output,
I want macro to find 3rd word, change its format, go to next 3rd word change the format again until the end of the document.

Like this:
I am human I am human I am human
Jun 29 '10 #4
NeoPa
32,556 Expert Mod 16PB
Is this a Microsoft Word related question by any chance? It doesn't help to leave out so much important information when posting a question (in a predominantly Access forum).
Jun 29 '10 #5
ADezii
8,834 Expert 8TB
@alphanj
Like NeoPa, I feel as though this may be a Word question. In any event, I wrote comparable code that will also work in Word. In this case each 3rd Word is formatted in Upper Case:
Expand|Select|Wrap|Line Numbers
  1. Dim strTestString As String
  2. Dim varSplit As Variant
  3. Dim intCounter As Integer
  4. Dim strBuild As String
  5.  
  6. strTestString = "She sells sea shells at the sea shore on a windy day"
  7.  
  8. varSplit = Split(strTestString, " ")
  9.  
  10. For intCounter = LBound(varSplit) To UBound(varSplit)
  11.   If (intCounter + 1) Mod 3 = 0 Then
  12.     strBuild = strBuild & " " & UCase(varSplit(intCounter))
  13.   Else
  14.     strBuild = strBuild & " " & varSplit(intCounter)
  15.   End If
  16. Next
  17.  
  18. Debug.Print Trim(strBuild)
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. She sells SEA shells at THE sea shore ON a windy DAY
Jun 29 '10 #6
NeoPa
32,556 Expert Mod 16PB
It's nevertheless an important question my friend, as Word has built-in objects and collections for things like words and paragraphs etc. It's not a good idea to reinvent the wheel. It introduces too many complications, and issues of compatibility etc. It's really down to the OP to make the question clear in the first place, or at least to respond intelligently to prompts.

To be clear, this is not a critique of your code in any way.
Jun 29 '10 #7
ADezii
8,834 Expert 8TB
@NeoPa
You are, of course, 100% correct. Just meant to be a Pointer in hopefully the right direction, since at least the Split() Function is supported in Word.
Jun 29 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: simonmarkjones | last post by:
Is there a simple way to capatalise the first letter of every word typed into a textbox on a form. Someone told me to use "Proper" but not sure if this is correct or how and where to use it. ...
0
by: Ricky Kam | last post by:
I'm using MODI, after the document is OCR, is there a way to select a word in a specific area? I know it can be done if someone use the mouse and do the selection manually, but if I want to achieve...
0
by: derelict | last post by:
Hey all, im getting desperate now. I have a macro running in Word 2003, when I run the macro it *should* put a 'bottom' cell border in each cell that has the style used - this included a border at...
0
by: A1000ma | last post by:
I am trying to develop a C# program to fill in the blanks in a Word Form. Everything works beautifully while the program is running. I had to go in to fix some links on our Web Site a couple of...
2
by: rando1000 | last post by:
How do I select every other, or every third, record in a table, based on a numeric ID field? I haven't had to do this in a couple years, and I can't remember. I think it has to do with Mod?
0
by: nkg6971 | last post by:
Hi All, Is there anyway to execute a excel macro from ms word macro? Code requested. Thanks in advacne.
0
by: priby | last post by:
Greetings to all, I am new to VB. In my VBA macro I am trying to access a data source(a text file) using the below code snippet. Dim TESTING As String .. ..
0
by: Vinodrajora | last post by:
Hello Everyone How are you? Can we create a macro in the word or excel files to convert into the HTML format for the specific coding (for Paragraph, tables and bulleted items) in the HTML...
0
by: alivip | last post by:
I write code to get most frequent words in the file I won't to implement bigram probability by modifying the code to do the following: How can I get every Token (word) and ...
2
by: wdangin | last post by:
Please help if anyone knows how to select a word in textbox using Click Even which result the same as the default DoubleClick even in textbox or any control? Thank you.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.