?
Solved

Microsoft Word 2000 Macro Loops

Posted on 2003-03-11
5
Medium Priority
?
352 Views
Last Modified: 2008-03-03
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
Comment
Question by:chrisandersoon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:pauloaguia
ID: 8115541
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
 
LVL 4

Author Comment

by:chrisandersoon
ID: 8116069
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
 
LVL 2

Accepted Solution

by:
rogerhammond earned 300 total points
ID: 8116078
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
 
LVL 2

Expert Comment

by:rogerhammond
ID: 8116084
And this way...you don't have to worry about Word idiosyncracies...you're just ripping raw text.
0
 
LVL 4

Author Comment

by:chrisandersoon
ID: 8116351
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question