none
Macro Issue - Copied from another computer RRS feed

  • Question

  • I am receiving an error when trying to run a macros that was copied (the code) from another computer and sent to me. I get 'Runtime error 5941" The requested member of the collection does not exist.

    When debugging I the bolded line below as the issue.

    Anyone have an idea of what I am missing here.

    Thanks!

    Sub CSTableToHtml1()
    '
    ' CSTabletoHTML1 Macro
    '
    '
        Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
            True
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = "^p"
            .Replacement.Text = "</td></tr>^p<tr><td>"
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        With Selection.Find
            .Text = "^t"
            .Replacement.Text = "</td>^t<td>"
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        Selection.MoveLeft Unit:=wdCharacter, Count:=1
        Selection.TypeText Text:="<table border=""1"">"
        Selection.TypeParagraph
        Selection.TypeText Text:="<tr><td>"
    End Sub

    Tuesday, October 22, 2013 3:15 PM

Answers