Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Cell Properties or XML data

I'm thinking of iterating through cell in a range and dumping/
documenting the value, formula and other attributes into a database so
that I can sort, filter, analyse cells. Tried range("a1").properties
(i) but properties does not seem to be supported in the object model?

Next, I would like to document properties which are different from
default - is there some approach to define what is default and then
use that as comparison?

I thought of looking at the .xlsx XML file but there's Excel specific
XML to decipher and to use an XML engine rather than the VBA / Excel
Object Model.

Any tips? Or any established tools that already do this?

Thanks.

Ananda
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Cell Properties or XML data

A cell is part of a Range and the Range Oject can have many Properites:

Sub CellProperties()
Dim r As Range
Set r = Range("A1")
With r
MsgBox (.Formula)
MsgBox (.Value)
MsgBox (.Value)
MsgBox (.Interior.ColorIndex)
End With
End Sub
--
Gary''s Student - gsnu200903


"AnandaSim" wrote:

I'm thinking of iterating through cell in a range and dumping/
documenting the value, formula and other attributes into a database so
that I can sort, filter, analyse cells. Tried range("a1").properties
(i) but properties does not seem to be supported in the object model?

Next, I would like to document properties which are different from
default - is there some approach to define what is default and then
use that as comparison?

I thought of looking at the .xlsx XML file but there's Excel specific
XML to decipher and to use an XML engine rather than the VBA / Excel
Object Model.

Any tips? Or any established tools that already do this?

Thanks.

Ananda

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Cell Properties or XML data

I've noticed that you have a habit of surrounding your MsgBox with
parentheses when you use them as a statement (that is, as a subroutine type
call, not as a function call). This is not a good idea and it will generate
an error if you try to include additional arguments; for example, if you try
to include a Button argument along with your Prompt argument.

This works...

MsgBox "Name?", vbQuestion

but this doesn't work...

MsgBox ("Name?", vbQuestion)

So, instead of doing this...

MsgBox (.Formula)

you should really be doing this...

MsgBox .Formula

or even this...

Call MsgBox(.Formula)

instead. Note that using the Call statement with the MsgBox, as shown in my
last example, requires the parentheses and it allows multiple arguments to
be specified. The above discussion, by the way, applies to any subroutine or
to any function that is call as if it were a subroutine.

The reason behind this is that VB considers anything surrounded by
parentheses that are *not* required by syntax to be an expression to be
evaluated. A single value inside of parentheses just evaluates to itself.
Two values inside parentheses without an operator of some sort between them
(the comma is not an operator) is not an expression and, hence, it can't be
evaluated. So, while you can get away with using parentheses around single
values subroutine arguments, it is not generally a good habit to get in.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
A cell is part of a Range and the Range Oject can have many Properites:

Sub CellProperties()
Dim r As Range
Set r = Range("A1")
With r
MsgBox (.Formula)
MsgBox (.Value)
MsgBox (.Value)
MsgBox (.Interior.ColorIndex)
End With
End Sub
--
Gary''s Student - gsnu200903


"AnandaSim" wrote:

I'm thinking of iterating through cell in a range and dumping/
documenting the value, formula and other attributes into a database so
that I can sort, filter, analyse cells. Tried range("a1").properties
(i) but properties does not seem to be supported in the object model?

Next, I would like to document properties which are different from
default - is there some approach to define what is default and then
use that as comparison?

I thought of looking at the .xlsx XML file but there's Excel specific
XML to decipher and to use an XML engine rather than the VBA / Excel
Object Model.

Any tips? Or any established tools that already do this?

Thanks.

Ananda


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Cell Properties or XML data

Thanks Rick! You make some very good points. I'll try your technique in the
future. Some people consider me extremely lazy and you approach will save me
two keystrokes per MsgBox call.
--
Gary''s Student - gsnu200903


"Rick Rothstein" wrote:

I've noticed that you have a habit of surrounding your MsgBox with
parentheses when you use them as a statement (that is, as a subroutine type
call, not as a function call). This is not a good idea and it will generate
an error if you try to include additional arguments; for example, if you try
to include a Button argument along with your Prompt argument.

This works...

MsgBox "Name?", vbQuestion

but this doesn't work...

MsgBox ("Name?", vbQuestion)

So, instead of doing this...

MsgBox (.Formula)

you should really be doing this...

MsgBox .Formula

or even this...

Call MsgBox(.Formula)

instead. Note that using the Call statement with the MsgBox, as shown in my
last example, requires the parentheses and it allows multiple arguments to
be specified. The above discussion, by the way, applies to any subroutine or
to any function that is call as if it were a subroutine.

The reason behind this is that VB considers anything surrounded by
parentheses that are *not* required by syntax to be an expression to be
evaluated. A single value inside of parentheses just evaluates to itself.
Two values inside parentheses without an operator of some sort between them
(the comma is not an operator) is not an expression and, hence, it can't be
evaluated. So, while you can get away with using parentheses around single
values subroutine arguments, it is not generally a good habit to get in.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
A cell is part of a Range and the Range Oject can have many Properites:

Sub CellProperties()
Dim r As Range
Set r = Range("A1")
With r
MsgBox (.Formula)
MsgBox (.Value)
MsgBox (.Value)
MsgBox (.Interior.ColorIndex)
End With
End Sub
--
Gary''s Student - gsnu200903


"AnandaSim" wrote:

I'm thinking of iterating through cell in a range and dumping/
documenting the value, formula and other attributes into a database so
that I can sort, filter, analyse cells. Tried range("a1").properties
(i) but properties does not seem to be supported in the object model?

Next, I would like to document properties which are different from
default - is there some approach to define what is default and then
use that as comparison?

I thought of looking at the .xlsx XML file but there's Excel specific
XML to decipher and to use an XML engine rather than the VBA / Excel
Object Model.

Any tips? Or any established tools that already do this?

Thanks.

Ananda



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing data: OLE DB and data link properties dialog Vivek Excel Programming 0 October 22nd 07 04:03 PM
Importing Data: OLE DB and data link properties dialog Vivek Excel Discussion (Misc queries) 0 October 22nd 07 03:59 PM
External Data Queries - Data Range Properties v Spreadsheet Format HLS Excel Discussion (Misc queries) 0 April 5th 06 11:09 AM
Properties transferring from excel cells to word file properties lubo Excel Programming 4 July 12th 05 11:24 AM
file properties with cell data? Geto Excel Programming 1 May 11th 05 04:11 PM


All times are GMT +1. The time now is 05:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"