热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

宏可将每个单元格更新为另一个html

我有一个宏,可将带有HTML标记的单元格转换为简单文本。但是我需要在一定范围

我有一个宏,可将带有HTML标记的单元格转换为简单文本。但是我需要在一定范围内奔跑。我尝试使用该范围,但出现错误。另外,我尝试使用activecell,但无法使其在范围内运行。

工作表如下所示:

宏可将每个单元格更新为另一个-html

'
' HTML Macro
'
' Keyboard Shortcut: Ctrl+Shift+H
'
Dim Ie As Object
Set Ie = CreateObject("InternetExplorer.Application")
With Ie
.Visible = False
.Navigate "about:blank"
.document.body.InnerHTML = Sheets("Planilha").Range("C2").Value
'update to the cell that contains HTML you want converted
.ExecWB 17,0
'Select all contents in browser
.ExecWB 12,2
'Copy them
activeSheet.Paste Destination:=Sheets("Planilha").Range("D2")
'update to the cell you want converted HTML pasted in
.Quit
End With
End Sub


我相信你想要这样的东西。

Dim Ie As Object
Set Ie = CreateObject("InternetExplorer.Application")
Dim columnWithHTML As Integer
Dim yourAmountOfRows As Integer
columnWithHTML = 1
yourAmountOfRows = 140
Ie.Navigate "about:blank"
Dim i As Integer
For i = 1 To yourAmountOfRows
Ie.document.body.InnerHTML = Cells(i,columnWithHTML).Value2
'paste the text near HTML column
Cells(i,columnWithHTML + 1).Value = Ie.document.body.InnerText
Next
Ie.Quit
Set Ie = Nothing

推荐阅读
author-avatar
张嫱的小屋_133
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有