[メモ] Microsoft AccessでHTMLタグ削除

CSVをAccessで加工しなきゃいけないときに重宝した。

1)標準モジュールに次のファンクションを追加します。

Option Compare Database
Option Explicit

Public Function ExterminateTags(ByVal html As String) As String
Dim reg
Set reg = CreateObject(“VBScript.RegExp”)
With reg
.Global = True
.IgnoreCase = True
End With
reg.Pattern = “<.*?>”
ExterminateTags = reg.Replace(html, “”)
End Function

2)クエリーの新規作成をします。

3)更新クエリーにします。

  クエリーのデザインビューから、メニューの[クエリー]-[更新]を押す

4)
フィールド HTML文字列
テーブル テーブル1
レコードの更新 ExterminateTags([HTML文字列])

などのようにします。

コメントをどうぞ

Commenting rules

  • Try to keep your comments as relevant as possible.
  • No HTML/JavaScript/BBcode.
  • Don't be abusive: No racism, homophobia or any other nastiness.
  • Feel free to express your opinion, but do so in an eloquent way.

If you do not respect these rules your comments may be edited or even deleted.