<pre>Private Sub Command3_Click() Dim xlObject As Object Dim xlWB As Object Set xlObject = CreateObject("Excel.Application") 'This Adds a new woorkbook, you could open the workbook from file also Set xlWB = xlObject.Workbooks.Add Clipboard.Clear 'Clear the Clipboard With xlObject.ActiveWorkbook.Activesheet xlObject.range("A1:H1").Select xlObject.Selection.merge xlObject.Cells(1, 1).Value = "DXTREAM FITNESS" xlObject.Cells(1, 1).Font.Size = 12 xlObject.Cells(1, 1).Font.fontstyle = "Bold" xlObject.Cells(2, 1).Value = DTPicker1.Value xlObject.Cells(2, 2).Value = "To" xlObject.Cells(2, 3).Value = DTPicker2.Value xlObject.Cells(1, 1).columnwidth = 9.86 xlObject.Cells(1, 3).columnwidth = 25 xlObject.Cells(1, 4).columnwidth = 10.43 xlObject.Cells(1, 5).columnwidth = 7.57 xlObject.Cells(1, 6).columnwidth = 7.14 xlObject.Cells(1, 7).columnwidth = 6.87 End With With MSGrid1 'Select Full Contents (You could also select partial content) .Col = 0 'From first column .Row = 0 'From first Row (header) .ColSel = .Cols - 1 'Select all columns .RowSel = .Rows - 1 'Select all rows Clipboard.SetText .Clip 'Send to Clipboard End With With xlObject.ActiveWorkbook.Activesheet .range("A3").Select 'Select Cell A1 (will paste from here, to different cells) .Paste 'Paste clipboard contents End With ' This makes Excel visible xlObject.Visible = True End Sub
DXTREAM FITNESS 10/01/2018 To 16/01/2018 Date ID Name Receipt No: Type Amount Vat Gross 13/01/2018 0 zaki 111 New 150 7.5 142.5 13/01/2018 0 zaki 111 New 150 7.5 142.5 13/01/2018 None None 11 Daily Collection 10 0.5 9.5
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)