
Private Sub btnExcel_Click()
'esporta in Excel nella cartella e con nome specificato di seguito.
FilterOn = False
Const NAME_REPORT_EXCEL = "\MIREPMOBFS1DatiUtente$ lcDesktopReport Elenco Generale.xlsx"
Dim oExcel As Object
On Error GoTo gest_err
Echo False
DoCmd.OutputTo acOutputForm, outputformat:=acFormatXLSX, outputfile:=NAME_REPORT_EXCEL, autostart:=False
Set oExcel = CreateObject("Excel.Application")
oExcel.workbooks.Open NAME_REPORT_EXCEL
With oExcel
'cancella le colonne A, B, J
.Sheets("m_elenco_generale").Range("A:B;J:J").Delete
'applica il filtro al primo rigo
.Sheets("m_elenco_generale").Range("A1").AutoFilter Field:=1
.activeworkbook.Close True
oExcel.Quit
End With
Set oExcel = Nothing
Echo True
MsgBox "Esportazione del registro in Excel effettuata con successo." & vbCrLf & "Controlla sul desktop", vbInformation, "Successful"
Exit Sub
gest_err:
If Not (oExcel Is Nothing) Then
oExcel.Quit
Set oExcel = Nothing
End If
MsgBox "L'esportazione del registro in Excel non è andata a buon fine." & vbCrLf & "Errore: " & Err.Description, vbExclamation, "Attenzione"
Exit Sub
End Sub |
Range("A1").Select
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
|
Private Sub btnExcel_Click()
'esporta in Excel nella cartella e con nome specificato di seguito.
FilterOn = False
'Const NAME_REPORT_EXCEL = "\MIREPMOBFS1DatiUtente$ lcDesktopReport Elenco Generale.xlsx"
Const NAME_REPORT_EXCEL = "C:UsersSilvia&AleDesktopReport Elenco Generale.xlsx"
Dim oExcel As Object
On Error GoTo gest_err
Echo False
DoCmd.OutputTo acOutputForm, outputformat:=acFormatXLSX, outputfile:=NAME_REPORT_EXCEL, autostart:=False
Set oExcel = CreateObject("Excel.Application")
oExcel.workbooks.Open NAME_REPORT_EXCEL
With oExcel
.Sheets("m_elenco_generale").Range("A:B;J:J").Delete
.Sheets("m_elenco_generale").Range("A1").AutoFilter Field:=1
.activeworkbook.Close True
oExcel.Quit
End With
Set oExcel = Nothing
Echo True
Range("A1").Select
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
MsgBox "Esportazione del registro in Excel effettuata con successo." & vbCrLf & "Controlla sul desktop", vbInformation, "Successful"
Exit Sub
gest_err:
If Not (oExcel Is Nothing) Then
oExcel.Quit
Set oExcel = Nothing
End If
MsgBox "L'esportazione del registro in Excel non è andata a buon fine." & vbCrLf & "Errore: " & Err.Description, vbExclamation, "Attenzione"
Exit Sub
End Sub
|
Private Sub btnExcel_Click()
'esporta in Excel nella cartella e con nome specificato di seguito.
FilterOn = False
Const NAME_REPORT_EXCEL = "\MIREPMOBFS1DatiUtente$ lcDesktopReport Elenco Generale.xlsx"
Dim oExcel As Object
On Error GoTo gest_err
Echo False
DoCmd.OutputTo acOutputForm, outputformat:=acFormatXLSX, outputfile:=NAME_REPORT_EXCEL, autostart:=False
Set oExcel = CreateObject("Excel.Application")
oExcel.workbooks.Open NAME_REPORT_EXCEL
With oExcel
.Sheets("m_elenco_generale").Range("A:B;J:J").Delete
.Sheets("m_elenco_generale").Range("A1").AutoFilter Field:=1
.Range("A1").Select
With .ActiveWindow
.SplitColumn = 0
.SplitRow = 1
.FreezePanes = True
End With
.activeworkbook.Close True
oExcel.Quit
End With
Set oExcel = Nothing
Echo True
MsgBox "Esportazione del registro in Excel effettuata con successo." & vbCrLf & "Controlla sul desktop", vbInformation, "Successful"
Exit Sub
gest_err:
If Not (oExcel Is Nothing) Then
oExcel.Quit
Set oExcel = Nothing
End If
MsgBox "L'esportazione del registro in Excel non è andata a buon fine." & vbCrLf & "Errore: " & Err.Description, vbExclamation, "Attenzione"
Exit Sub
End Sub
|
