• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Microsoft Word 2000 Macro Loops

I have a document that is about 100 pages long.  The format I have it in is a .txt file.  
it has a list of numbers ex.

123421433434  234234234 23423422 234234234X
345345234244  234234234 42342342 234242423X
234234423433  234234234 23423445 123412323X

Now my problem is is that this list of numbers a hundred pages long is being entered into
a database the data base reads in white space and then moves to the next line.  Where I placed
the X is where my file ends.  I need it to be another 15 characters long.  What I have is a macro
that will enter in 15 'W's, Why 'W', NO Reason, and then replace 'W' with ' '.  what I have it doing right now is:

           Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/11/2003 by Chris Anderson
'
    Do Until EOF()
    Selection.TypeText Text:="wwwwwwwwwwwwwwww"
    Selection.MoveDown Unit:=wdLine, Count:=1
    Loop
   
End Sub

K know my Do until loop is wrong because I need a (1) but don't know where to put anything.  And it also doesn't seem to know what Do Until EOF(1) is in word.  I just want it to do all the 'W' until the end of the file and then replace the 'W' with ' ' and that would fix my shortened whitespace problem.  Thanks.
0
chrisandersoon
Asked:
chrisandersoon
  • 2
  • 2
1 Solution
 
pauloaguiaCommented:
SWo, basically what you want is to insert 15 spaces before each X right? Why not do an extended replace of all 'X' with '               X' ?

Paulo
0
 
chrisandersoonAuthor Commented:
Sorry I worded that wrong,  I need to add fifteen spaces after the X, and the X was just a place marker.  It could be:
123421433434  234234234 23423422 2342342346
345345234244  234234234 42342342 2342424237
234234423433  234234234 23423445 1234123233

The X was just to show were I needed to extend it past.  Thanks. For the response.
0
 
rogerhammondCommented:
Sub whatever()

    Dim x As String
    Dim outText As String
    Const fifteenSpaces = "               "
   
    Open "c:\megalist.txt" For Input As #1
    Open "c:\revisedlist.txt" For Output As #2
    Line Input #1, x
   
    While Not EOF(1)
        outText = x & fifteenSpaces
        print #2, outText
        Input #1, x
    Wend
    Close #1
    Close #2
   
End Sub


I'm taking a guess at the Print statement (it'll be close) as I butchered a similar routine that helped me intelligently populate an excel spreadsheet from a Lotus Notes address book and I only wanted certain fields.
0
 
rogerhammondCommented:
And this way...you don't have to worry about Word idiosyncracies...you're just ripping raw text.
0
 
chrisandersoonAuthor Commented:
Wow did you nail that one.  I appreciate it, I don't do much coding, but networking. Hopefully someday I can give you some help.  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now