PC Review


Reply
Thread Tools Rate Thread

delete row in excel object model

 
 
Fredrated
Guest
Posts: n/a
 
      30th Jan 2009
Can anyone provide the code, if possible, to delete a row from a spreadsheet
using the excel object model? The transferspreadsheet method makes the first
row a field name row, and I would like to delete it after the spreadsheet is
created.

Thanks.

Fred
 
Reply With Quote
 
 
 
 
Clifford Bass
Guest
Posts: n/a
 
      30th Jan 2009
Hi Fred,

How about just specifying False for the HasFieldNames (fifth) parameter?

Clifford Bass

"Fredrated" wrote:

> Can anyone provide the code, if possible, to delete a row from a spreadsheet
> using the excel object model? The transferspreadsheet method makes the first
> row a field name row, and I would like to delete it after the spreadsheet is
> created.
>
> Thanks.
>
> Fred

 
Reply With Quote
 
Fredrated
Guest
Posts: n/a
 
      30th Jan 2009
Thanks for your reply.
According to the documantation, hasfieldnames only applies to imported data,
exporting to a spreadsheet always has field names in the first row. And
indeed I can believe that, because I set that param to false yet the field
names appear anyway.

Fred

"Clifford Bass" wrote:

> Hi Fred,
>
> How about just specifying False for the HasFieldNames (fifth) parameter?
>
> Clifford Bass
>
> "Fredrated" wrote:
>
> > Can anyone provide the code, if possible, to delete a row from a spreadsheet
> > using the excel object model? The transferspreadsheet method makes the first
> > row a field name row, and I would like to delete it after the spreadsheet is
> > created.
> >
> > Thanks.
> >
> > Fred

 
Reply With Quote
 
Clifford Bass
Guest
Posts: n/a
 
      30th Jan 2009
Hi Fred,

That is a bummer :-( It would make the most sense. Oh well. Try
something like this:

Dim appExcel As New Excel.Application
Dim wkbExported As Excel.Workbook
Dim strFile As String

strFile = Environ("USERPROFILE") & "\Desktop\C Table.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "C", strFile

Set wkbExported = appExcel.Workbooks.Open(strFile)
wkbExported.ActiveSheet.Range("A1").Delete
wkbExported.Save
wkbExported.Close
Set wkbExported = Nothing
appExcel.Quit
Set appExcel = Nothing

You will need to add the "Microsoft Excel nn.n Object Library" to your
references (Tools menu, References) for it to work.

Clifford Bass

"Fredrated" wrote:

> Thanks for your reply.
> According to the documantation, hasfieldnames only applies to imported data,
> exporting to a spreadsheet always has field names in the first row. And
> indeed I can believe that, because I set that param to false yet the field
> names appear anyway.
>
> Fred

 
Reply With Quote
 
Fredrated
Guest
Posts: n/a
 
      30th Jan 2009
Thanks, I just handed off the product to people that want to create reports
from the spreadsheets. I will try this and add it next week.

I created my own equiv. of the first row by unioning a table of column
descriptors with the output query, so we don't need the first row of field
names. I am sure they will be glad to see the field-names first row removed
in code.

Fred

"Clifford Bass" wrote:

> Hi Fred,
>
> That is a bummer :-( It would make the most sense. Oh well. Try
> something like this:
>
> Dim appExcel As New Excel.Application
> Dim wkbExported As Excel.Workbook
> Dim strFile As String
>
> strFile = Environ("USERPROFILE") & "\Desktop\C Table.xls"
> DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "C", strFile
>
> Set wkbExported = appExcel.Workbooks.Open(strFile)
> wkbExported.ActiveSheet.Range("A1").Delete
> wkbExported.Save
> wkbExported.Close
> Set wkbExported = Nothing
> appExcel.Quit
> Set appExcel = Nothing
>
> You will need to add the "Microsoft Excel nn.n Object Library" to your
> references (Tools menu, References) for it to work.
>
> Clifford Bass
>
> "Fredrated" wrote:
>
> > Thanks for your reply.
> > According to the documantation, hasfieldnames only applies to imported data,
> > exporting to a spreadsheet always has field names in the first row. And
> > indeed I can believe that, because I set that param to false yet the field
> > names appear anyway.
> >
> > Fred

 
Reply With Quote
 
Clifford Bass
Guest
Posts: n/a
 
      30th Jan 2009
Hi Fred,

You are welcome! And good luck,

Clifford Bass

"Fredrated" wrote:

> Thanks, I just handed off the product to people that want to create reports
> from the spreadsheets. I will try this and add it next week.
>
> I created my own equiv. of the first row by unioning a table of column
> descriptors with the output query, so we don't need the first row of field
> names. I am sure they will be glad to see the field-names first row removed
> in code.
>
> Fred

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Object Model =?Utf-8?B?RGFycmlu?= Microsoft Excel Programming 2 3rd Oct 2007 04:22 PM
Excel Object Model Jeff Wright Microsoft Excel Programming 4 9th Oct 2006 02:34 PM
Confusion about how the Window object fits into the Excel object model Josh Sale Microsoft Excel Programming 11 15th Apr 2005 06:46 PM
Excel object model Alan Hutchins Microsoft Excel Programming 0 17th Sep 2004 11:32 AM
Excel Object Model MM Microsoft Access Macros 1 19th Feb 2004 12:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 PM.