Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Word Macro: loop through end of file?

Reply  
Thread Tools
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
03-May-2009, 09:57 AM #16
i have attached a sample doc.
Attached Files
File Type: doc sample.doc (23.5 KB, 115 views)
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 11:39 AM #17
There is no way to change the color of a single element in a true numbered list in MS Word. You either have to change all the number colors or not. The only way to overcome this feature in Word is to go into the AutoCorrect options and turn off the "Automatic Numbered List" option. This would however require that you recreate all the existing numbered lists. Is that an option for you? What version of MS Word are you using?

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
03-May-2009, 11:41 AM #18
ok i've just run this code
Code:
ActiveDocument.ConvertNumbersToText
so now i have all text.
now what to do ?
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 11:58 AM #19
Try the code below.

Code:
Sub ChangeColor()

ActiveDocument.ConvertNumbersToText

For Each vWord In ActiveDocument.Words

If vWord.Underline = 1 Then
vWord.Select
Selection.HomeKey Unit:=wdLine
Do Until InStr(1, Selection.Text, ".") > 0
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Loop
Selection.Font.Color = wdColorRed
End If

Next

End Sub
Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
03-May-2009, 12:11 PM #20
it works but makes red some lines as well...
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 12:22 PM #21
Run the macro and attach the modified file so I can see what you are talking about.

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
03-May-2009, 04:54 PM #22
here is a better sample, please look at it

in a few words your code turns this:
Code:
1.	This is a testbla blab
       la bla blabla asdasd 
2.	Aasdasd 
3.	Asdrttr8776
4.	Sdfdfhhfg
into this:

Code:
1.	This is a testbla blab
 la bla blabla asdasd 
2.	Aasdasd 
3.	Asdrttr8776
4.	Sdfdfhhfg
Attached Files
File Type: doc sample2.doc (25.0 KB, 71 views)
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 06:17 PM #23
This is going to be difficult unless I have the actual document you are trying to convert since I'll need to write some special logic into the macro. Does it contain sensitive info?? Could you email it to me?

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
03-May-2009, 06:26 PM #24
here is a sample.
please look at it, as it's very similar to my original doc.

thanks for understanding..
Attached Files
File Type: doc sample2.doc (25.0 KB, 83 views)
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 07:17 PM #25
Try this

Code:
Sub ChangeColor()

ActiveDocument.ConvertNumbersToText

For Each vWord In ActiveDocument.Words

If vWord.Underline = 1 Then
vWord.Select
Selection.HomeKey Unit:=wdLine

If IsEmpty(vStart) Then
vStart = Selection.Information(wdHorizontalPositionRelativeToPage)
End If

If Selection.Information(wdHorizontalPositionRelativeToPage) = vStart Then
Do Until InStr(1, Selection.Text, ".") > 0
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Loop
Selection.Font.Color = wdColorRed
Else
GoTo Skip
End If
End If
Skip:
Next

End Sub
Regards,
Rollin
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
03-May-2009, 08:37 PM #26
Quote:
Originally Posted by kejo View Post
ok i've just run this code
Code:
ActiveDocument.ConvertNumbersToText
so now i have all text.
now what to do ?
Boy, I wish I had known that last week....
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 08:47 PM #27
Quote:
Originally Posted by slurpee55 View Post
Boy, I wish I had known that last week....
Don't feel bad, I just found out about it myself

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
03-May-2009, 09:17 PM #28
Rollin how did you learn all this stuff ??? i couldn't find it on google...
i really don't know how to thank you ... i appreciate your help. thanks !
slurpee55's Avatar
Computer Specs
Distinguished Member with 7,837 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
03-May-2009, 09:45 PM #29
I think he channels someone....
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
03-May-2009, 10:08 PM #30
So I take it the macro worked? I pretty much taught myself VBA over the past 7 years. I started like most people and just recorded basic stuff using the macro recorder and then stepped through the generated code line by line to learn what each line did. After a while you just start to learn about all the object properties and methods. The key to becoming good at VBA is practice. I like challenges and one of the ways that I practice is by helping people like you with real world problems.

Regards,
Rollin
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:18 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.