Re: Excel Export - Field Names in First Row of Spreadsheet
- From: "Rich1234" <Rich1234@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 13 Oct 2005 01:36:16 -0700
At the moment I am using TransferSpreadsheet to create the Excel file.
How do I open the Excel file and delete the first row of records using
automation? I've never done this before. The TransferSpreadsheet is carried
out in VBA called from a command button (not in a macro.) Or is the first
way you suggest a better way of doing this?
One other thought: I am including the time and date in the filename when
creating the Excel file, using the following code:
Dim sNow As String
sNow = Format(Date, " dd-mm-yyyy") & " " & Format(Time, "hhmm")
DoCmd.TransferSpreadsheet acExport, 8, "VRM for Export", "C:\My
Documents\DSCP ANPR" & sNow & ".xls", True
If I need to include code to open the Excel file (to delete the first row),
I will (presumably) need to include the filename again. So using the
following for the filename would work (right?):
"VRM for Export", "C:\My Documents\DSCP ANPR" & sNow & ".xls"
My only thought is whether this would include the time as it "now" is,
rather than as it was when the Excel file was saved.... i.e. if the realtime
has just changed to the next minute (in the milliseconds it has taken for the
code to be processed), would the variable sNow now show the updated minute?
If it would, then the filename would be cited above would now have changed!
If it would still show the "old" time, there would be no problem.
Can you advise me on this point as well?
Thank you
rich
"Ken Snell [MVP]" wrote:
> Comments inline...
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
> "Rich1234" <Rich1234@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:FE57C4B8-2277-4408-8F3B-F4555312165C@xxxxxxxxxxxxxxxx
> > Hi
> >
> > I have done a lot of "digging" through posts to try to find the answers I
> > need.....
> >
> > I am setting up an export to excel. I have read in the Access help File,
> > TransferSpreadsheet Action, that it is not possible to export to Excel
> > without the Field Names appearing in the first row of the spreadsheet.
>
> This is correct. TransferSpreadsheet will always export the field names when
> exporting to an EXCEL file.
>
>
> > (Is there any way around this?
>
> Not unless you use VBA code to open a recordset for the query you're
> exporting, open an EXCEL file using Automation, and write the data directly
> into the spreadsheet. Or use TransferSpreadsheet to export the query, then
> use Automation to open the spreadsheet and delete the first row.
>
>
> > Or is it possible to have the field names appear
> > in the "horizontal axis" at the top of the spreadsheet where A, B, C etc
> > appear as column names by default?)
>
> Nope, not to my knowledge.
>
> >
> > I have read in posts that a way to put the field names in column headers
> > in
> > the spreadsheet is to use a "make table query." How do I do this? I
> > would
> > like to have a button that the user presses on an Access form to save just
> > one field from one table to an Excel file.
>
> I'm not understanding this. A "make table query" has no advantages for what
> you want to do. You can export a query directly, and you can "change" the
> field names in the query using calculated fields in place of the original
> fields. For example, if you wanted the "field name" of a field to be "User
> Name" instead of "UserName" (the name in the table), you'd have a calculated
> field that would look like this in the QBE design window:
> User Name: [UserName]
>
> This means you can use customized "field names" for the export, and these
> customized names will appear in the first row of the spreadsheet.
>
>
>
> > This is new to me... if you could post what is needed step by step
> > (including code) I'd be very grateful.
> >
> > TIA
> > Rich
> >
>
>
>
.
- Follow-Ups:
- Re: Excel Export - Field Names in First Row of Spreadsheet
- From: Ken Snell [MVP]
- Re: Excel Export - Field Names in First Row of Spreadsheet
- References:
- Excel Export - Field Names in First Row of Spreadsheet
- From: Rich1234
- Excel Export - Field Names in First Row of Spreadsheet
- Prev by Date: RE: Export to Excel - Date in Filename
- Next by Date: Re: How to convert a long integer number to time format
- Previous by thread: Re: Excel Export - Field Names in First Row of Spreadsheet
- Next by thread: Re: Excel Export - Field Names in First Row of Spreadsheet
- Index(es):
Relevant Pages
|