How do I run a query then have it create a excel file? Macro? VBA? Without doing it manually?
K kitty77 Registered User. Local time Today, 07:01 Joined May 27, 2019 Messages 710 Oct 22, 2019 #1 How do I run a query then have it create a excel file? Macro? VBA? Without doing it manually?
theDBguy I’m here to help Staff member Local time Today, 04:01 Joined Oct 29, 2018 Messages 21,454 Oct 22, 2019 #2 Hi. You should be able to use either one, but I prefer to use VBA.
pbaldy Wino Moderator Staff member Local time Today, 04:01 Joined Aug 30, 2003 Messages 36,124 Oct 22, 2019 #3 TransferSpreadsheet and OutputTo are the two most common/easiest methods. I use VBA but I think both are macro actions too.
TransferSpreadsheet and OutputTo are the two most common/easiest methods. I use VBA but I think both are macro actions too.
K kitty77 Registered User. Local time Today, 07:01 Joined May 27, 2019 Messages 710 Oct 22, 2019 #4 I'm using this, it works but it exports it as if you checked off to export with formatting. Can I change that? DoCmd.OutputTo ObjectType:=acOutputQuery, ObjectName:="sales", OutputFormat:=acFormatXLS, Outputfile:="C:\aaa\test.xls"
I'm using this, it works but it exports it as if you checked off to export with formatting. Can I change that? DoCmd.OutputTo ObjectType:=acOutputQuery, ObjectName:="sales", OutputFormat:=acFormatXLS, Outputfile:="C:\aaa\test.xls"
theDBguy I’m here to help Staff member Local time Today, 04:01 Joined Oct 29, 2018 Messages 21,454 Oct 22, 2019 #5 kitty77 said: I'm using this, it works but it exports it as if you checked off to export with formatting. Can I change that? DoCmd.OutputTo ObjectType:=acOutputQuery, ObjectName:="sales", OutputFormat:=acFormatXLS, Outputfile:="C:\aaa\test.xls" Click to expand... Try TransferSpreadheet. I think it doesn't format the data.
kitty77 said: I'm using this, it works but it exports it as if you checked off to export with formatting. Can I change that? DoCmd.OutputTo ObjectType:=acOutputQuery, ObjectName:="sales", OutputFormat:=acFormatXLS, Outputfile:="C:\aaa\test.xls" Click to expand... Try TransferSpreadheet. I think it doesn't format the data.
K kitty77 Registered User. Local time Today, 07:01 Joined May 27, 2019 Messages 710 Oct 22, 2019 #6 Can you give me an example using mine? Thanks...
K kitty77 Registered User. Local time Today, 07:01 Joined May 27, 2019 Messages 710 Oct 22, 2019 #7 I got it! Thanks for that.
theDBguy I’m here to help Staff member Local time Today, 04:01 Joined Oct 29, 2018 Messages 21,454 Oct 22, 2019 #8 kitty77 said: Can you give me an example using mine? Thanks... Click to expand... Code:Copy to clipboard DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "sales", "c:\aaa\test.xlsx", True
kitty77 said: Can you give me an example using mine? Thanks... Click to expand... Code:Copy to clipboard DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "sales", "c:\aaa\test.xlsx", True
theDBguy I’m here to help Staff member Local time Today, 04:01 Joined Oct 29, 2018 Messages 21,454 Oct 22, 2019 #9 kitty77 said: I got it! Thanks for that. Click to expand... Oh, you got it. Good. Glad to hear you got it figured out. Good luck!
kitty77 said: I got it! Thanks for that. Click to expand... Oh, you got it. Good. Glad to hear you got it figured out. Good luck!