Discussione:
Salvare file excel
(troppo vecchio per rispondere)
Marco75
2010-07-15 06:54:46 UTC
Permalink
Ciao,

ho un pulsante in una form access che esporta in excel una tabella
pivot :

DoCmd.OpenForm "M_Pivot", acFormPivotTable
DoCmd.RunCommand acCmdPivotTableExportToExcel

Ora, come faccio a salvare in automatico questo file in una cartella
magari
mettendo data e ora nel nome del file?
grazie

Marco
Geppo Beach
2010-07-25 21:39:22 UTC
Permalink
Post by Marco75
Ciao,
ho un pulsante in una form access che esporta in excel una tabella
DoCmd.OpenForm "M_Pivot", acFormPivotTable
DoCmd.RunCommand acCmdPivotTableExportToExcel
Ora, come faccio a salvare in automatico questo file in una cartella
magari
mettendo data e ora nel nome del file?
Se è salvata come "Pivot", puoi provare con questa riga di codice:

DoCmd.OutputTo acOutputForm, "M_Pivot", acFormatXLS, "C:\Pivot " &
Format(Now(), "dd-mm-yyyy hh-nn") & ".xls"
Post by Marco75
grazie
Marco
--
Ciao
Geppo
Geppo Beach
2010-07-25 21:50:26 UTC
Permalink
....erhhm, per il momento non tenere conto del post precedente.
--
Ciao
Geppo
Marco75
2010-07-29 09:47:37 UTC
Permalink
Post by Geppo Beach
....erhhm, per il momento non tenere conto del post precedente.
--
Ciao
Geppo
Ciao,

perchè non ne devo tenere conto? non funziona?
se possibile, vorrei anche salvare il file excel esportato in una
cartella
Grazie

Marco
Geppo
2010-07-29 10:51:24 UTC
Permalink
Post by Marco75
Post by Geppo Beach
....erhhm, per il momento non tenere conto del post precedente.
--
Ciao
Geppo
Ciao,
perchè non ne devo tenere conto? non funziona?
il metodo "OutputTo" non va se l'oggetto è aperto in qualsiasi modalità
visualizzazione Pivot.
Post by Marco75
se possibile, vorrei anche salvare il file excel esportato in una
cartella
l'unica cosa che mi viene in mente adesso è questa (fa un po' schifo?), se
ti sta bene:

Function EsportaPivot()
Dim vExc As Object, i, vNameFile

DoCmd.OpenForm "M_Pivot", acFormPivotTable
DoCmd.RunCommand acCmdPivotTableExportToExcel

On Error Resume Next

riprova:
DoEvents
Set vExc = GetObject(, "Excel.Application")

If Err.Number = 429 Then
vExc = Nothing
GoTo riprova:
End If

vNameFile = "C:\Pivot salvato il " & Format(Now(), "dd-mm-yyyy hh-nn")
vExc.Workbooks(1).SaveAs FileName:=vNameFile, FileFormat:=xlNormal
vExc.Quit

End Function
Post by Marco75
Grazie
Marco
--
Ciao
Geppo
Marco75
2010-07-29 09:48:57 UTC
Permalink
Post by Geppo Beach
....erhhm, per il momento non tenere conto del post precedente.
--
Ciao
Geppo
Scusa ho letto di fretta!!
hai già inserito nel codice il salvataggio del file con data e ora...
Loading...