MY poor code:
Code: Select all
Private Sub Command2_Click()
If Me.LNRAR.Caption > "" Then
DATANOW = Format(CDate(Now), "YYYYMMDD")
Set OBJXL = CreateObject("Excel.Application")
Set WBXL = OBJXL.Workbooks.Open(STRPATHXLS)
OBJXL.Visible = False
Set WSXL = WBXL.Sheets("REPORT")
Dim R As Long, C As Long, NUMC As Integer
With Me.MSFlexGrid1
NUMC = .Cols - 1
For R = 1 To .Rows - 1
For C = 1 To NUMC
Debug.Print .TextMatrix(R, C)
Next C
Next R
End With
WBXL.SaveAs STRPATHXLSFILE & "REPORT_" & DATANOW & ".xls"
WBXL.Close SaveChanges:=False
Set WBXL = Nothing
Set WSXL = Nothing
OBJXL.Quit
Set OBJXL = Nothing
Else
Beep
Me.LAZIONI.Caption = "NESSUN DATO DA ESPORTARE!"
DoEvents
Sleep (1500)
Me.LAZIONI.Caption = ""
End If
End Sub
the workbook is in c:\mydir\
the sheet is named report
start the copy from column 1 of msflexgrid
Public OBJXL As Object, WBXL As Object, WSXL As Object