Strange behaviour

W

WhytheQ

If I run the following the the string appears in the cell WITH all the
tags

ThisWorkbook.Sheets("Sheet1").Cells(10, 4) = "<html><table
border=""1""><th>helloworld</th></table></html>"

but if I copy that string from another application into a cell in
Excel then the result is 'helloworld' in a box i.e the tags have
become active

How can I change the code so the tags are active?

Any help appreciated
Jason.
 
J

John Coleman

If I run the following the the string appears in the cell WITH all the
tags

ThisWorkbook.Sheets("Sheet1").Cells(10, 4) = "<html><table
border=""1""><th>helloworld</th></table></html>"

but if I copy that string from another application into a cell in
Excel then the result is 'helloworld' in a box i.e the tags have
become active

How can I change the code so the tags are active?

Any help appreciated
Jason.

If you add a reference to the Microsoft Forms2.0 Object Library (via
tools/references) the following seems to work:

Sub test()

Dim DataObj As New DataObject
Dim HTML As String
Dim myRange As Range

HTML = "<html><table border=""1""><th>helloworld</th></table></html>"

Set myRange = ThisWorkbook.Sheets("Sheet1").Cells(10, 4)

DataObj.SetText (HTML)
DataObj.PutInClipboard

myRange.PasteSpecial
End Sub
 
W

WhytheQ

If you add a reference to the Microsoft Forms2.0 Object Library (via
tools/references) the following seems to work:

Sub test()

Dim DataObj As New DataObject
Dim HTML As String
Dim myRange As Range

HTML = "<html><table border=""1""><th>helloworld</th></table></html>"

Set myRange = ThisWorkbook.Sheets("Sheet1").Cells(10, 4)

DataObj.SetText (HTML)
DataObj.PutInClipboard

myRange.PasteSpecial
End Sub

Cheers John - much appreciated

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top