+ Reply to Thread
Results 1 to 2 of 2

Help with a Macro (MS Word)

  1. #1
    Registered User
    Join Date

    Post Help with a Macro (MS Word)

    I am working with a macro in MS Word which will not function properly. I wonder if the data can be cut/pasted into Excel, and a similar macro run from there, but I don't have enough experience to know if this is possible, or how to do it. I would like to do this in MS Word, but ideally, the information would be easier to upload to our database in Excel format. Essentially, this is the situation:

    I have a .doc with hundreds of Student Names and ID #'s read from a card-swiper keyboard. The data comes up in this format:


    *(This is altered, sample data)*

    The relevant information is hidden inside:


    The ID and name being in Red. The first and last name would be "J. Samplename"

    I have an old macro which is supposed to transform the data into two columns, one which has the name, one which has the number. From here, we upload the information onto our database.

    The macro I have been given, (which was apparantly written in 2002), has a "bug" at a certain point.

    Does anyone know of a pre-existing macro which could be easily modified to operate with this data? Is there a way to de-bug the pre-existing macro and convince it to function correctly?

    Here is the macro I have to work with, the bug line highlighted:


    Sub Macro1()
    ' Macro1 Macro
    ' Macro recorded 06/07/02 by Student Staff
    With Selection.Find
    .Text = "^p5677"
    .Replacement.Text = "5677"
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
    NumColumns:=3, NumRows:=10, Format:=wdTableFormatNone, ApplyBorders:=True _
    , ApplyShading:=True, ApplyFont:=True, ApplyColor:=True, ApplyHeadingRows _
    :=True, ApplyLastRow:=False, ApplyFirstColumn:=True, ApplyLastColumn:= _
    False, AutoFit:=False
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.MoveUp Unit:=wdLine, Count:=1
    Selection.MoveRight Unit:=wdCharacter, Count:=32
    Selection.MoveDown Unit:=wdParagraph, Count:=12, Extend:=wdExtend
    Selection.MoveUp Unit:=wdParagraph, Count:=1, Extend:=wdExtend
    Selection.InsertRows 1
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:="ID Number"
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:="Last Name/First Initial"
    Selection.MoveLeft Unit:=wdWord, Count:=6, Extend:=wdExtend
    Selection.Font.Bold = wdToggle
    End Sub


    Anyone who could help with this would be a hero to my office, and to me! The deadline for this is this weekend, and otherwise I will have to enter the data manually. I appreciate any suggestions or fixes!

    Enthused thanks in advance...

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    Santiago Chile
    can you post a sample xls where you have imported the data so I can help you?
    I need to know which columns you what the name and card number.
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1