Excel データから html タグを削除するマクロに書き込もうとしています。<*> このパターンを検索して、それらを空白に置き換えたいだけです。また、'“' などの特殊文字や、if(typeof(dstb)!= "undefined"){ dstb();} などのタグも削除する必要があります。
今まで書いたコードでは、ファイル名をマクロにハードコーディングする必要がありますが、これは望ましくありません。
コード:
Sub UnescapeCharacters()
sheetname = "2011 Publications" 'file name goes here
Dim sheet As Worksheet
Set sheet = Me.Worksheets(sheetname)
For Row = 1 To sheet.UsedRange.Rows.Count
For Column = 1 To sheet.UsedRange.Columns.Count
Dim cell As Range
Set cell = sheet.Cells(Row, Column)
ReplaceCharacter cell, """, """"
ReplaceCharacter cell, ",", ""
ReplaceCharacter cell, " ", ""
ReplaceCharacter cell, "•", ""
ReplaceCharacter cell, "</ul>", ""
ReplaceCharacter cell, "<ul>", ""
ReplaceCharacter cell, "<b>", ""
ReplaceCharacter cell, "</b>", ""
ReplaceCharacter cell, "<i>", ""
ReplaceCharacter cell, "</i>", ""
ReplaceCharacter cell, "</li>", ""
ReplaceCharacter cell, "<li>", ""
ReplaceCharacter cell, "</br>", ""
ReplaceCharacter cell, "<br />", ""
ReplaceCharacter cell, "</p>", ""
ReplaceCharacter cell, "<p>", ""
Next Column
Next Row
End Sub
Sub ReplaceCharacter(ByRef cell As Range, ByVal find As String, ByVal replacement As String)
Dim result As String
cell.Value = Replace(cell.Text, find, replacement, 1, -1)
End Sub
誰か助けてくれませんか?