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
04-May-2009, 08:28 AM #31
very nice
you have a deep experience in this field.

your last piece of code is working like a charm:
Code:
Sub ChangeColor01()

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
thank you very much man.

by the way: what office version are you running?

Last edited by kejo; 04-May-2009 at 08:33 AM..
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
04-May-2009, 08:32 AM #32
I am still running Office 2000. I have Office 2003 on disk but I am lazy and was never in a hurry to install it since the older version works fine for everything I do.

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
04-May-2009, 10:47 AM #33
is there a way to run this macro for all the .doc files in my folder ??
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
04-May-2009, 10:51 AM #34
Yes. Does the folder in question contain any other files other than Word files that need to be processed by the macro?

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
04-May-2009, 10:54 AM #35
only my docs....
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
04-May-2009, 04:39 PM #36
What version of MS Word / Office are you using??

Regards,
Rollin
kejo's Avatar
Member with 70 posts.
 
Join Date: Dec 2006
04-May-2009, 05:03 PM #37
i am using 2003, but i have 2007 too
Rollin_Again's Avatar
Senior Member with 4,273 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
04-May-2009, 06:57 PM #38
Here is the updated code

Code:
Sub LoopDirectory()

Application.FileDialog(msoFileDialogFolderPicker).Show
vDirectory = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1)

If Len(Dir(vDirectory & "\" & "NewFiles", vbDirectory)) = 0 Then
    MkDir vDirectory & "\" & "NewFiles"
End If

vFile = Dir(vDirectory & "\" & "*.*")

Do While vFile <> ""

    Documents.Open FileName:=vDirectory & "\" & vFile

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


ActiveDocument.SaveAs (vDirectory & "\" & "NewFiles" & "\" & ActiveDocument.Name)
ActiveDocument.Close

vFile = Dir
Loop

End Sub


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:20 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.