Private Sub Command1_Click()
On Error GoTo Err_XLS
Dim objApp As Object
Dim objWb As Object
Dim objSh As Object
Dim lngR As Long, lngC As Long
Set objApp = CreateObject("Excel.Application")
Set objWb = objApp.WorkBooks.Add
Set objSh = objWb.ActiveSheet
For lngR = 0 To MSFlexGrid1.Rows - 1
For lngC = 0 To MSFlexGrid1.Cols - 1
objSh.Cells(lngR + 1, lngC + 1) = _
MsFlexGrid1.TextMatrix(lngR, lngC)
Next lngC
Next lngR
objWb.SaveCopyAs "c:\ruta\nombre.xls"
objWb.Saved = True
Exit_XLS:
On Local Error Resume Next
objApp.Close
objApp.Quit
Set objSh = Nothing
Set objWb = Nothing
Set objApp = Nothing
Exit Sub
Err_XLS:
MsgBox "(" & Err.Number & ") " & Err.Description, vbCritical, "Xls"
Resume Exit_XLS
End Sub