>One thing I noticed when handling oExcel is that the interface to it (and to browser object as well, not necessarily related to this) is quirky, at least. One thing that it doesn't like is going too deep in a hierarchy of reference. Some things like
That has been my experience as well. And it seems to be that case for most automation (ie. Outlook, internet explorer, Word, Excel). Everytime you change level in the hierarchy make a reference to it. Here is perfect example, the internet explorer document property.
o = CREATEOBJECT('internetexplorer.application')
o.Navigate2("www.microsoft.com")
o.Document.
And yet if you do this
o = CREATEOBJECT('internetexplorer.application')
o.Navigate2("www.microsoft.com")
oDoc=o.Document
oDoc.
>>Trial and error. Recently someone else had asked me about FitTopagesWide and did not know why it didn't and after trial and error, I noticed also that the order that properties are set seems to make a difference. For example if you move the orientation setting after the FitTopagesWide and the .FitToPagesTall, the result are not as expexted. Also after testing the code posted here, I too get an error message, and after moving the orientation out of the with/endwith, the error went away.
>
>One thing I noticed when handling oExcel is that the interface to it (and to browser object as well, not necessarily related to this) is quirky, at least. One thing that it doesn't like is going too deep in a hierarchy of reference. Some things like
>
>
oExcel.ActiveSheet.Range("blabla").selection.rows
>
>may not work at all (OK, this one might - but I've seen a few which don't), but
>
>
oSh=oExcel.activesheet
>oRng=oSh.range("blabla")
>oSel=orng.Selection
>nRows=oSel.rows
>
>seems to work much better - and (surprise) the properties of these intermediate variables are visible by intellisense while debugging, which otherwise doesn't work if you got more than two levels of hierarchy. I have no explanation for this, it's probably something in VB or whichever tool they use to do stuff, and the way it exports its PEMs in TLB files.