Ask Experts Questions for FREE Help !
Ask
    lemond's Avatar
    lemond Posts: 0, Reputation: 1
    New Member
     
    #1

    Mar 21, 2007, 09:05 AM
    VB list
    I just created a macro for creating a list in Word. The problem I am having is that it will not cut the selections.

    Sub EditEmailList()
    Dim List As String 'variable name goes here As datatype
    strSearchText = " ("
    TopOfFile
    SearchDown List 'variable name
    While Selection.Find.Found
    Selection.MoveRight 'use IntelliSense (type a dot "." after "Selection") to move the cursor to the right
    Selection.TypeBackspace 'use IntelliSense to make program type a backspace
    Repeat
    Selection.TypeText Chr(9)
    Selection.MoveLeft 'use IntelliSense to move the cursor to the left
    Selection.Extend 'use IntelliSense to extend the selection
    SearchUp " "
    If Selection.Find.Found = True Then
    Selection.MoveRight
    Selection.EscapeKey 'use IntelliSense to perform the same action as the Esc key on the keyboard
    Selection.Cut 'use IntelliSense to cut the selection
    Selection.TypeBackspace 'use IntelliSense to type a backspace
    Selection.MoveUp Unit:=wdParagraph
    Selection.PasteAppendTable 'use IntelliSense to paste the clipboard content
    Selection.TypeText Chr(9)
    Else
    End
    End If
    Selection.MoveDown 'use IntelliSense to move down one paragraph
    SearchDown List
    Wend
    Selection.WholeStory
    Selection.ParagraphFormat.Reset
    Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=3, NumRows:=6
    Selection.Tables(1).AutoFitBehavior (wdAutoFitContent)
    TopOfFile
    Selection.InsertRowsAbove 1
    Selection.Font.Bold = True
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.TypeText Text:="LastName"
    Selection.MoveRight Unit:=wdCell
    Selection.TypeText Text:="FirstName"
    Selection.MoveRight Unit:=wdCell
    Selection.TypeText Text:="Email"
    TopOfFile
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = ")"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    'following is message output telling user what the program did
    MsgBox "[FirstName LastName (e-mail address)]" & " for " & intCnt & " different records"
    End Sub
    Sub TopOfFile()
    Selection.HomeKey Unit:=wdStory
    End Sub
    Sub SearchDown(strPassedText As String)
    Selection.Find.Text = strPassedText
    Selection.Find.Forward = True
    Selection.Find.Wrap = wdFindStop
    Selection.Find.MatchCase = False
    Selection.Find.MatchWholeWord = False
    Selection.Find.Format = False
    Selection.Find.Execute
    End Sub
    Sub SearchUp(strPassedText As String)
    Selection.Find.Text = strPassedText
    Selection.Find.Forward = False
    Selection.Find.Wrap = wdFindStop
    Selection.Find.MatchCase = False
    Selection.Find.MatchWholeWord = False
    Selection.Find.Format = False
    Selection.Find.Execute
    End Sub
    CliffARobinson's Avatar
    CliffARobinson Posts: 1,416, Reputation: 101
    Ultra Member
     
    #2

    Jan 13, 2012, 06:16 PM
    Please review the code from MSDN:

    How to: Create a List of Items

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Visual basic [ 1 Answers ]

Dim first As Long Dim second As Long Dim sign As String Dim FirstValueEntered As Boolean Private Sub Command1_Click(Index As Integer) If FirstValueEntered = True Then TextDisplay.Text = TextDisplay.Text & Command1(Index).Caption second = Val(TextDisplay.Text)

Visual basic 6 [ 1 Answers ]

Hi! I am facing difficulty in preparing SRS(software requirement specification) of my semister project which is Credit Card System(visual basic 6) please give me some suggesion. Thank you

Visual basic [ 1 Answers ]

How can I disable maximise button of a form but minimise and close button should be enable?

Visual Basic [ 1 Answers ]

I want to add icon in the button which I have used in my visual basic program. How can I do that. Please help.


View more questions Search