Converting Msflexgrid content to Excel
-
Hi All, I am using the following code to convert the MSflexgrid content to Excel. This code is also working fine. It opens MS Excel and paste the contents of MSFlexgrid. But now for me, when i click the button it should ask Open, Save (or)Cancel kind of dialog box, and if press Save it should show Save dialog box and give filename and save it, or if we Give open it should open the excel sheet. Please help me how to do that. Code: Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Set xlApp = New Excel.Application Set xlWB = xlApp.Workbooks.Add Clipboard.Clear 'Clear the Clipboard With MSFlexGrid1 '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 xlApp.ActiveWorkbook.ActiveSheet .Range("C2").Select 'Select Cell A1 (will paste from here, to different cells) .Paste 'Paste clipboard contents End With ' This makes Excel visible xlApp.Visible = True Thanks in Advance, Regards
-
Hi All, I am using the following code to convert the MSflexgrid content to Excel. This code is also working fine. It opens MS Excel and paste the contents of MSFlexgrid. But now for me, when i click the button it should ask Open, Save (or)Cancel kind of dialog box, and if press Save it should show Save dialog box and give filename and save it, or if we Give open it should open the excel sheet. Please help me how to do that. Code: Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Set xlApp = New Excel.Application Set xlWB = xlApp.Workbooks.Add Clipboard.Clear 'Clear the Clipboard With MSFlexGrid1 '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 xlApp.ActiveWorkbook.ActiveSheet .Range("C2").Select 'Select Cell A1 (will paste from here, to different cells) .Paste 'Paste clipboard contents End With ' This makes Excel visible xlApp.Visible = True Thanks in Advance, Regards
aaraaayen wrote:
and if press Save it should show Save dialog box and give filename and save it, or if we Give open it should open the excel sheet.
Then save the data to a temporary .xls file in the %TEMP% folder and launch this .xls file so Excel launches and opens the file itself.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007