I needed for one of my application to Paste selected part of Excel sheet, including text, Format, colors.... into a grid (here ssGrid2 from Steve)
After doing some research, I never saw such code for VBA/VB6/Twin
So I wrote code to retrieve XML (and HTML too) from a copy (CTRL+C) from Excel, and managed the Paste into my app
The code posted here should be updated to reflect the grid you are using, but, it needs very small changes to fit your own grid.
Here is the call
You can also find in the module code to do the oposite, copy a grid to the clipboard as HTML data, to paste it in Outlook/Excel/Word... as a grid
Clipboard_Module.basClipboard_Excel_Module.bascCustomClipboard.cls
After doing some research, I never saw such code for VBA/VB6/Twin
So I wrote code to retrieve XML (and HTML too) from a copy (CTRL+C) from Excel, and managed the Paste into my app
The code posted here should be updated to reflect the grid you are using, but, it needs very small changes to fit your own grid.
Here is the call
Code:
Dim oClipBoard As cCustomClipboard
Dim sText As String
Dim bXML As Boolean
Set oClipBoard = New cCustomClipboard
If (oClipBoard.ClipboardOpen(Me.hWnd)) Then
Call oClipBoard.GetTextData(oClipBoard.AddFormat("XML Spreadsheet"), sText)
If LenB(sText) = 0 Then
Call oClipBoard.GetTextData(oClipBoard.AddFormat(oClipBoard.CliboardFormat_HTML), sText)
Else
bXML = True
End If
End If
Call oClipBoard.ClipboardClose
Set oClipBoard = Nothing
If LenB(sText) > 0 Then
' *** Texte en XML ou HTML
If bXML Then
Call Excel_Clipboard_XML(oGrid, nStartRow, nStartCol, UTF8_Decode(sText))
Else
Call Excel_Clipboard_HTML(oGrid, nStartRow, nStartCol, UTF8_Decode(sText))
End If
End If
Clipboard_Module.basClipboard_Excel_Module.bascCustomClipboard.cls