Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2015, 05:51 PM
jrhlavac jrhlavac is offline Capitalize one to two words if they are the only words on a line Windows 10 Capitalize one to two words if they are the only words on a line Office 2010 32bit
Novice
Capitalize one to two words if they are the only words on a line
 
Join Date: Oct 2015
Posts: 1
jrhlavac is on a distinguished road
Default Capitalize one to two words if they are the only words on a line

Quick question. My process of reformatting pasted documents from various formats (PDF,Outlook/HTML,etc.) has been quite the headache. My macro is getting to be pretty impressive in its power, however I was wondering if any knowledgeable VB coders could advise on this last headache...



I'm dealing with Resumes, and after stripping the formatting, I like to capitalize headers for each section in plain text.

Ie

Name
Address
Phone
Email

SUMMARY
xxx

PROFESSIONAL EXPERIENCE
xxx

EDUCATION
xxx

Is there a macro that can be intelligent enough to only capitalize say, Education, in the instance that it is the only word on the line consisting of A-Z characters? I say A-Z because sometimes strange space characters get through from time to time in front of the word...

What about a Macro that erases any character that is not A-Z or 0-9 from the start of a line?

And finally, is it possible to make the instances of "Professional Experience", "professional experience", "experience" or "work history" into "PROFESSIONAL EXPERIENCE", only if each example is the only word or pair of words on that given line? I.E., not capitalizing the word experience if it appears in the body of a paragraph elsewhere.

Thanks for the wisdom. I know I ask a lot, but I have faith someone might already have a few tricks for me!
Reply With Quote
  #2  
Old 10-08-2015, 08:19 PM
macropod's Avatar
macropod macropod is offline Capitalize one to two words if they are the only words on a line Windows 7 64bit Capitalize one to two words if they are the only words on a line Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For a macro that handles the reformatting of text sourced from a wide range of material, including PDFs emails & web pages, see: https://www.msofficeforums.com/word/...html#post32907

That may also resolve your issue with 'strange space characters get through from time to time in front of the word'.

As for a macro to capitalise words in scenarios like you said, you might try something along the lines of:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Para As Paragraph
For Each Para In ActiveDocument.Paragraphs
  With Para.Range
    .End = .End - 1
    If .ComputeStatistics(wdStatisticWords) < 3 Then
      .Text = Trim(UCase(.Text))
    End If
  End With
Next
Application.ScreenUpdating = False
End Sub
The other examples require nothing more complicated than a Find/Replace. For example:
Find = ^pprofessional experience^p
Replace = ^pPROFESSIONAL EXPERIENCE^p
such processing could be incorporated into a macro based on the one in the above link.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capitalize one to two words if they are the only words on a line VBA to solve duplicate words in one line Bookmaster Word VBA 7 02-03-2015 04:30 PM
Capitalize one to two words if they are the only words on a line How to mark underlined words in a sentence as A, B, C, D (beneath the words) thudangky Word 13 12-12-2013 02:22 AM
Is there a way to capitalize the all the words except the prepositions? Jamal NUMAN Word 2 08-06-2011 11:46 PM
Why Words doesn’t show the style of the selected words automatically???? Jamal NUMAN Word 0 04-14-2011 03:20 PM
Creating different spacing for words on the same line Jenjen80 Word 1 08-12-2010 05:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft