Hello All,
What this is possible to get data from Clipboard(copy data) from Microsoft Excel data ?
I need to import data from copy data in sheet excel.
thanks
Printable View
Hello All,
What this is possible to get data from Clipboard(copy data) from Microsoft Excel data ?
I need to import data from copy data in sheet excel.
thanks
do u want to paste from clipboard to excel sheet? one sheet to another sheet? what exactly u want to do? VBA or VB6?
this looks like VBA question
excel has its own copy methods, that will work to copy (or paste) most data or other excel objects to the clipboard, but has no method to work directly with the clipboard object, as is done in vb6
i have posted an activex dll, in code bank, that will allow working with the clipboard object in VBA or VBS
http://www.vbforums.com/showthread.php?t=585616
this example print excel cel A1 data into form, u can change filename, sheetname cell etc...
Code:Private Sub Form_Load()
Dim xlsApp As Object, xlsWB1 As Object, xlsWS1 As Object, Rng As Object
Dim FileName As String, StrInfo As String
FileName = "d:\a1.xls"
Set xlsApp = CreateObject("Excel.Application")
xlsApp.Visible = False
Set xlsWB1 = xlsApp.Workbooks.Open(FileName)
Set xlsWS1 = xlsWB1.worksheets("Sheet1")
With xlsWS1
StrInfo = .cells(1, 1)
Me.AutoRedraw = True
Me.Print StrInfo 'print cell data
End With
xlsWB1.Close
xlsApp.quit
'clean up
Set xlsApp = Nothing
Set xlsWB1 = Nothing
Set xlsWS1 = Nothing
End Sub
thanks for your replay.
Your sample code is that we need to make one excel file a1.xls.
but, i need to copy data from excel sheet that i do not need to make a1.xls file.
i try to use Clipboard.GetText
but the result is text only and i that is hard to get valid value from real data (excel sheet data).
Do you have idea for this condition ?
thank you
yes, i tried your code.
but, my question is where we get data from clipboard to process into your code ?
where do u need to paste the clipboard data? into excel or vb6 form? see this code wil print text from clipboard into form.
Code:Private Sub Form_Load()
Dim StrInfo As String
StrInfo = Clipboard.GetText(1)
Me.AutoRedraw = True
Me.Print StrInfo 'print text from clipboard
End Sub
what i need is same like this article:
http://www.catenary.com/howto/clipbrd.html
but that for image, and i need for excel data.
may be u need to show an excel sheet as image in form, ok add a picture box and try this code, the size of the image is depends on usedrange
u can also set the image to form's picture.Code:Private Sub Form_Load()
Dim xlsApp As Object, xlsWB1 As Object, xlsWS1 As Object, Rng As Object
Dim FileName As String
FileName = "d:\a1.xls"
Set xlsApp = CreateObject("Excel.Application")
xlsApp.Visible = False
Set xlsWB1 = xlsApp.Workbooks.Open(FileName)
Set xlsWS1 = xlsWB1.worksheets("Sheet1")
xlsApp.displayalerts = False
xlsWS1.usedrange.Copy
Picture1.AutoRedraw = True
Picture1.AutoSize = True
Set Picture1.Picture = Clipboard.GetData(vbCFBitmap)
xlsWB1.Close savechanges:=False
xlsApp.quit
Set xlsApp = Nothing
Set xlsWB1 = Nothing
Set xlsWS1 = Nothing
End Sub
u can size the image using 2 picturebox, set 1 picbox invisible, autosize = true, then use StreachBlt to draw in another picbox with its size.
after reading all the posts again, i am still not sure what you are trying to achive
if you want to copy an image of the excel window to a picturebox, you can use the microsoft example for printing forms, just do not print
the sample code, is at http://support.microsoft.com/default...b;en-us;161299