0

我创建了 VBA excel 脚本来从网站获取数据。

当它捕获时11-01,excel 会自动转换为 11-Jan (11/01/2012) 而不是原来的 11-01。

不将 11-01 转换为 11-Jan 的方法是什么?

地址单位邮政
惹兰伦彭 11-01 128791

谢谢。

Set clip = New DataObject
clip.SetText "<html><table><tr>" _
& "<td>" & ieSearchGet.outerHTML & "</td>" _
& "</tr></table></html>"
clip.PutInClipboard
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell)
    ActiveCell.Offset(1, 0).Select
Loop
ActiveSheet.PasteSpecial "Unicode Text"
4

2 回答 2

2

I think the best is to just change the format of the cell you want to paste your data in, before doing so. Does the following work ?

Set clip = New DataObject
                clip.SetText "<html><table><tr>" _
                & "<td>" & ieSearchGet.outerHTML & "</td>" _
                & "</tr></table></html>"
                clip.PutInClipboard
                ActiveCell.Offset(1, 0).Select
                Do While Not IsEmpty(ActiveCell)
                    ActiveCell.Offset(1, 0).Select
                    Selection.NumberFormat = "@" 'Format as Text the selected cell
                Loop
                ActiveSheet.PasteSpecial "Unicode Text"
于 2012-11-08T12:04:12.583 回答
0

You could try adding the character "'" (that is, a single quote) before the text you paste.

I have never tried to do this, so this will probably not be quite the right code. You will probably have to experiment. But it's a start:

clip.SetText "<html><table><tr>" _
    & "<td>'" & ieSearchGet.outerHTML & "</td>" _
    & "</tr></table></html>"
于 2012-11-08T12:05:02.380 回答