Im using VB.net I am trying to code copying data from a datagridveiw and open a new excel workbook and pasting the data into the sheet starting at cell A1.
So far I have the code to copy the data from the datagridview, open excel but cannot find any way to automatically paste the data with the user pasting the data.
Can anyone help please!
Dim objExcel As Application = New Application
Dim objWB As Excel.Workbook
Try
Me.DataGridView1.SelectAll()
Clipboard.SetDataObject(Me.DataGridView1.GetClipboardContent())
objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objWB = objExcel.Workbooks.Open("Test.xls")
'Code Here
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, strTitle)
End Try