VBA insert carriage return between bold and unbold text Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!When using range.find to find bold text it won't find if the entire selection is bold!Remove carriage return in UnixWhat are carriage return, linefeed, and form feed?See line breaks and carriage returns in editorFind and replace - Add carriage return OR NewlineWhat is the difference between a “line feed” and a “carriage return”?Can I font format the output of a word macro?Carriage return in .txt file - VBA MacrosSeparating large file and inserting carriage returns based on stringRange.Find() text with carriage return Excel VBAMacro to insert comments on keywords in selected text in a Word doc?

8 Prisoners wearing hats

How to answer "Have you ever been terminated?"

How to down pick a chord with skipped strings?

How do I find out the mythology and history of my Fortress?

Does classifying an integer as a discrete log require it be part of a multiplicative group?

How to tell that you are a giant?

Irreducible of finite Krull dimension implies quasi-compact?

Should I use a zero-interest credit card for a large one-time purchase?

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

Did MS DOS itself ever use blinking text?

When the Haste spell ends on a creature, do attackers have advantage against that creature?

Compare a given version number in the form major.minor.build.patch and see if one is less than the other

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Is there a kind of relay only consumes power when switching?

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

What does the "x" in "x86" represent?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

For a new assistant professor in CS, how to build/manage a publication pipeline

Is there such thing as an Availability Group failover trigger?

What do you call the main part of a joke?

Is there any way for the UK Prime Minister to make a motion directly dependent on Government confidence?

Extracting terms with certain heads in a function

How to compare two different files line by line in unix?

Why aren't air breathing engines used as small first stages



VBA insert carriage return between bold and unbold text



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!When using range.find to find bold text it won't find if the entire selection is bold!Remove carriage return in UnixWhat are carriage return, linefeed, and form feed?See line breaks and carriage returns in editorFind and replace - Add carriage return OR NewlineWhat is the difference between a “line feed” and a “carriage return”?Can I font format the output of a word macro?Carriage return in .txt file - VBA MacrosSeparating large file and inserting carriage returns based on stringRange.Find() text with carriage return Excel VBAMacro to insert comments on keywords in selected text in a Word doc?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a word document that is a transcription of an interview. The moderators comments are in bold and respondents comments are not bold. It is a long continuous run on of bold and un-bold text. I need to add a carriage return so that there is a blank line between the moderator and the respondents questions. I found the code below to insert a carriage return between specific text, but I don't know how to change it to insert between bold and un-bold text. Any help is greatly appreciated!



Sub Test()
ActiveDocument.Paragraphs(1).Range.Text = "Foo" & Chr(11) & "Bar"
End Sub









share|improve this question
























  • stackoverflow.com/questions/975033/…

    – Tim Williams
    Mar 8 at 18:57

















0















I have a word document that is a transcription of an interview. The moderators comments are in bold and respondents comments are not bold. It is a long continuous run on of bold and un-bold text. I need to add a carriage return so that there is a blank line between the moderator and the respondents questions. I found the code below to insert a carriage return between specific text, but I don't know how to change it to insert between bold and un-bold text. Any help is greatly appreciated!



Sub Test()
ActiveDocument.Paragraphs(1).Range.Text = "Foo" & Chr(11) & "Bar"
End Sub









share|improve this question
























  • stackoverflow.com/questions/975033/…

    – Tim Williams
    Mar 8 at 18:57













0












0








0








I have a word document that is a transcription of an interview. The moderators comments are in bold and respondents comments are not bold. It is a long continuous run on of bold and un-bold text. I need to add a carriage return so that there is a blank line between the moderator and the respondents questions. I found the code below to insert a carriage return between specific text, but I don't know how to change it to insert between bold and un-bold text. Any help is greatly appreciated!



Sub Test()
ActiveDocument.Paragraphs(1).Range.Text = "Foo" & Chr(11) & "Bar"
End Sub









share|improve this question
















I have a word document that is a transcription of an interview. The moderators comments are in bold and respondents comments are not bold. It is a long continuous run on of bold and un-bold text. I need to add a carriage return so that there is a blank line between the moderator and the respondents questions. I found the code below to insert a carriage return between specific text, but I don't know how to change it to insert between bold and un-bold text. Any help is greatly appreciated!



Sub Test()
ActiveDocument.Paragraphs(1).Range.Text = "Foo" & Chr(11) & "Bar"
End Sub






vba carriage-return textformat






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 18:56









Tim Williams

89.5k97087




89.5k97087










asked Mar 8 at 18:51









LansP8LansP8

12




12












  • stackoverflow.com/questions/975033/…

    – Tim Williams
    Mar 8 at 18:57

















  • stackoverflow.com/questions/975033/…

    – Tim Williams
    Mar 8 at 18:57
















stackoverflow.com/questions/975033/…

– Tim Williams
Mar 8 at 18:57





stackoverflow.com/questions/975033/…

– Tim Williams
Mar 8 at 18:57












1 Answer
1






active

oldest

votes


















0














This is what I came up with, it uses one sub to insert a break after bold text, and then calls another sub to do the same for nonbold text. I used the constant 'vbCrLf' which stands for Visual Basic Carriage Return Line Feed, it's equal to Chr(13) + Chr(10), and I believe it's the best practice for compatibility when inserting a line break in a document as opposed to Chr(11).



Sub InsertBreakAfterBold()
'Select entire document
Selection.WholeStory

'Make each .Method belong to Selection.Find for readability
With Selection.Find
'Set search criteria for bold font
.Font.Bold = True
'Find next occurrence
.Execute

'Each time bold text is found add a line break to the end of it then find the next one
Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With

'Repeat process for nonbold text
Call InsertBreakAfterNonbold
End Sub

Sub InsertBreakAfterNonbold()
Selection.WholeStory

With Selection.Find
.Font.Bold = False
.Execute

Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With
End Sub


Microsoft's VBA reference was my biggest resource to make this: https://docs.microsoft.com/en-us/office/vba/api/overview/word






share|improve this answer























  • Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

    – LansP8
    Mar 11 at 14:43











  • @LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

    – Tyler N
    Mar 11 at 15:03











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069298%2fvba-insert-carriage-return-between-bold-and-unbold-text%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














This is what I came up with, it uses one sub to insert a break after bold text, and then calls another sub to do the same for nonbold text. I used the constant 'vbCrLf' which stands for Visual Basic Carriage Return Line Feed, it's equal to Chr(13) + Chr(10), and I believe it's the best practice for compatibility when inserting a line break in a document as opposed to Chr(11).



Sub InsertBreakAfterBold()
'Select entire document
Selection.WholeStory

'Make each .Method belong to Selection.Find for readability
With Selection.Find
'Set search criteria for bold font
.Font.Bold = True
'Find next occurrence
.Execute

'Each time bold text is found add a line break to the end of it then find the next one
Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With

'Repeat process for nonbold text
Call InsertBreakAfterNonbold
End Sub

Sub InsertBreakAfterNonbold()
Selection.WholeStory

With Selection.Find
.Font.Bold = False
.Execute

Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With
End Sub


Microsoft's VBA reference was my biggest resource to make this: https://docs.microsoft.com/en-us/office/vba/api/overview/word






share|improve this answer























  • Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

    – LansP8
    Mar 11 at 14:43











  • @LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

    – Tyler N
    Mar 11 at 15:03















0














This is what I came up with, it uses one sub to insert a break after bold text, and then calls another sub to do the same for nonbold text. I used the constant 'vbCrLf' which stands for Visual Basic Carriage Return Line Feed, it's equal to Chr(13) + Chr(10), and I believe it's the best practice for compatibility when inserting a line break in a document as opposed to Chr(11).



Sub InsertBreakAfterBold()
'Select entire document
Selection.WholeStory

'Make each .Method belong to Selection.Find for readability
With Selection.Find
'Set search criteria for bold font
.Font.Bold = True
'Find next occurrence
.Execute

'Each time bold text is found add a line break to the end of it then find the next one
Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With

'Repeat process for nonbold text
Call InsertBreakAfterNonbold
End Sub

Sub InsertBreakAfterNonbold()
Selection.WholeStory

With Selection.Find
.Font.Bold = False
.Execute

Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With
End Sub


Microsoft's VBA reference was my biggest resource to make this: https://docs.microsoft.com/en-us/office/vba/api/overview/word






share|improve this answer























  • Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

    – LansP8
    Mar 11 at 14:43











  • @LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

    – Tyler N
    Mar 11 at 15:03













0












0








0







This is what I came up with, it uses one sub to insert a break after bold text, and then calls another sub to do the same for nonbold text. I used the constant 'vbCrLf' which stands for Visual Basic Carriage Return Line Feed, it's equal to Chr(13) + Chr(10), and I believe it's the best practice for compatibility when inserting a line break in a document as opposed to Chr(11).



Sub InsertBreakAfterBold()
'Select entire document
Selection.WholeStory

'Make each .Method belong to Selection.Find for readability
With Selection.Find
'Set search criteria for bold font
.Font.Bold = True
'Find next occurrence
.Execute

'Each time bold text is found add a line break to the end of it then find the next one
Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With

'Repeat process for nonbold text
Call InsertBreakAfterNonbold
End Sub

Sub InsertBreakAfterNonbold()
Selection.WholeStory

With Selection.Find
.Font.Bold = False
.Execute

Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With
End Sub


Microsoft's VBA reference was my biggest resource to make this: https://docs.microsoft.com/en-us/office/vba/api/overview/word






share|improve this answer













This is what I came up with, it uses one sub to insert a break after bold text, and then calls another sub to do the same for nonbold text. I used the constant 'vbCrLf' which stands for Visual Basic Carriage Return Line Feed, it's equal to Chr(13) + Chr(10), and I believe it's the best practice for compatibility when inserting a line break in a document as opposed to Chr(11).



Sub InsertBreakAfterBold()
'Select entire document
Selection.WholeStory

'Make each .Method belong to Selection.Find for readability
With Selection.Find
'Set search criteria for bold font
.Font.Bold = True
'Find next occurrence
.Execute

'Each time bold text is found add a line break to the end of it then find the next one
Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With

'Repeat process for nonbold text
Call InsertBreakAfterNonbold
End Sub

Sub InsertBreakAfterNonbold()
Selection.WholeStory

With Selection.Find
.Font.Bold = False
.Execute

Do While .Found
Selection.Text = Selection.Text + vbCrLf
.Execute
Loop

End With
End Sub


Microsoft's VBA reference was my biggest resource to make this: https://docs.microsoft.com/en-us/office/vba/api/overview/word







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 11 at 13:43









Tyler NTyler N

417




417












  • Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

    – LansP8
    Mar 11 at 14:43











  • @LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

    – Tyler N
    Mar 11 at 15:03

















  • Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

    – LansP8
    Mar 11 at 14:43











  • @LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

    – Tyler N
    Mar 11 at 15:03
















Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

– LansP8
Mar 11 at 14:43





Amazing! That did the trick. You must be a wizard because that churned through 50 pages of messy text and came out perfect. Can't say thank you enough for your help with that.

– LansP8
Mar 11 at 14:43













@LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

– Tyler N
Mar 11 at 15:03





@LansP8 You're absolutely welcome, thank you for the compliment. I'm glad it did the trick for you; I can't imagine doing that manually for 50 pages.

– Tyler N
Mar 11 at 15:03



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069298%2fvba-insert-carriage-return-between-bold-and-unbold-text%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович