【发布时间】:2016-04-29 10:23:21
【问题描述】:
我将以下文本存储在工作表的单元格中
<tr onmouseover="this.style.backgroundColor='#74eb61';" onmouseout="this.style.backgroundColor='#e8e8e8';">
现在,当我将其复制并粘贴到记事本时,我会在每个引号之后得到一个额外的引号符号,因此它变成了以下字符串
<tr onmouseover=""this.style.backgroundColor='#74eb61';"" onmouseout=""this.style.backgroundColor='#e8e8e8';"">
您可以通过以下方式重新创建它:
复制这段文字:
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.hovertable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.hovertable th {
background-color:#009fe3;
color:#FFFFFF;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
table.hovertable tr {
background-color:#e8e8e8;
}
table.hovertable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
</style>
<!-- Table goes in the document BODY -->
<table class="hovertable">
<th colspan="4">Info Header</th>
<tr onmouseover="this.style.backgroundColor='#74eb61';" onmouseout="this.style.backgroundColor='#e8e8e8';">
<td>Item 1A</td><td>Item 1B</td><td>Item 1C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#74eb61';" onmouseout="this.style.backgroundColor='#e8e8e8';">
<td>Item 2A</td><td>Item 2B</td><td>Item 2C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#74eb61';" onmouseout="this.style.backgroundColor='#e8e8e8';">
<td>Item 3A</td><td>Item 3B</td><td>Item 3C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#74eb61';" onmouseout="this.style.backgroundColor='#e8e8e8';">
<td>Item 4A</td><td>Item 4B</td><td>Item 4C</td>
</tr>
<tr onmouseover="this.style.backgroundColor='#74eb61';" onmouseout="this.style.backgroundColor='#e8e8e8';">
<td>Item 5A</td><td>Item 5B</td><td>Item 5C</td>
</tr>
</table>
并粘贴到 Excel 中的任何单元格
然后复制单元格内容并粘贴到记事本上,你会发现多余的引号
【问题讨论】:
-
删除字符串
Stystr = Replace(Trim(wh.Range("A2").Text),"""","")中已有的引号 -
同样在声明
Dim Stystr, endHTb, StRTb, tbstr, tbTag, ctb As String中,只有ctb 被标注为String类型。其他都是变种。要将它们全部标注为String类型,请编写Dim Stystr as String, endHTb as String, StRTb as String ... -
@ScottHoltzman 不,我认为这不会起作用,因为每个
""都被""""替换,"被""替换,所以无法区分哪个需要替换 -
我不确定你所说的每个
""都被""""替换并且"被""替换是什么意思?你在说我的公式吗?还是你的代码的结果? -
您能否在设置变量后立即在
Stystr上执行 debug.print 并让我知道是否从一开始就出现了额外的引号?因为我刚刚对其进行了测试,并且无法复制您的问题(目前)。
标签: string vba excel concatenation