Hi
I need a code for a macro to select every 3rd word after selection.
7 3522 ADezii 8,834
Recognized Expert Expert @alphanj
Have no idea as to what you are requesting, kindly be more specific, and post concrete examples.
So you want something like this?
Input:
I am human I am human I am human
Output:
human human human
@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 NeoPa 32,569
Recognized Expert Moderator MVP
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).
ADezii 8,834
Recognized Expert Expert @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: - Dim strTestString As String
-
Dim varSplit As Variant
-
Dim intCounter As Integer
-
Dim strBuild As String
-
-
strTestString = "She sells sea shells at the sea shore on a windy day"
-
-
varSplit = Split(strTestString, " ")
-
-
For intCounter = LBound(varSplit) To UBound(varSplit)
-
If (intCounter + 1) Mod 3 = 0 Then
-
strBuild = strBuild & " " & UCase(varSplit(intCounter))
-
Else
-
strBuild = strBuild & " " & varSplit(intCounter)
-
End If
-
Next
-
-
Debug.Print Trim(strBuild)
OUTPUT: - She sells SEA shells at THE sea shore ON a windy DAY
NeoPa 32,569
Recognized Expert Moderator MVP
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.
ADezii 8,834
Recognized Expert Expert @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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
Please can someone help.
Many thanks in advance!
|
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 the same thing with code, how do
I do it? Would someone should be a code sample please?
I'm using VB.net/VS.net
Thank you in advance
|
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 the top of the table and one at the bottom, like a set of container border for a table with no border within it. i.e
table heading
_______________________________ << top border
text in the table spanning multiple rows and columns...
|
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 days later and found any Word Document containing links now shows the code instead of the link. i.e. {HYPERLINK "Executive%20Summary%20for%20CSI.doc"} instead of CSI. I have traced this error down to my program but don't know what is causing it.
...
|
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?
| |
by: nkg6971 |
last post by:
Hi All,
Is there anyway to execute a excel macro from ms word macro? Code requested.
Thanks in advacne.
|
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
..
..
|
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 files.
Please explain from A to Z
Thanks and have a nice day
Vinod Kumar
|
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 PreviousToken(Previous word) and frequency and probability
From text file and put each one in cell in table
For example if the text file content is
"Every man has a price. Every woman has a price."
First Token(word) is "Every" PreviousToken(Previous...
|
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.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |