AnsweredAssumed Answered

vrf VRF - continued beginner mental block with Excel ActiveX

Question asked by VRFuser on Feb 9, 2000
I am aware that this subject has been beaten to the ground recently, and I
apologize for resurrecting what may have been explained before I joined the
group last week.

**********
That is what this list is for.

1)  How can this be translated into VEE?
Using the Application Object:
Use the Application property to return the Application object. The following
example applies the Windows property to the Application object.
Application.Windows("book1.xls").Activate

***************
This is the very same in VEE, the only thing that is missing is how to get
the Application object. You do that with getObject or createObject
functions. If there is no Excel open you say
Set myXL = createObject("Excel.Application");
Where the arguments that can go or that do go in this function call came
from I do not know. You always need an application so I always start there.
I like to think of the '.' operator as "is a", "has a", and "do a". If you
are abstracting up it means "is a". Referencing from within, "has a", and
calling a function of, "do a". The way you determine the "has a"'s is by
using the function object browser. In the window to the left select active X
objects, top select Excel, middle select application. To the right you see
all the objects that an application "has", and all the functions an
application can "do". So if you create an application object "myXL", then
anything in the form "myXL.hasa" is legal, where "hasa" is everything in
that right most window. When you select a particular function or object in
the right you see the syntax for it at the bottom. [option] denotes optional
parameters. You can get VB examples and further explanation by clicking
Help.

The following example creates a Microsoft Excel worksheet object in another
application and then opens a workbook in Microsoft Excel.
Set xl = CreateObject("Excel.Sheet")
xl.Application.Workbooks.Open "newbook.xls"

***************
This is why I say the arguments to the function CreateObject are fuzzy, they
like to use Excel.Sheet alot. I always start with Excel.Application. Use it
like this for consistency and understanding.
Set xl = CreateObject("Excel.Application");
xl.Workbooks.Open("newbook.xls");

notice the slight syntactical changes necessary from VB to VEE. Alot of
excel functions take arguments like this
xl.Workbooks.Worksheets.Add(Before:= "my last sheet", count:= 2)
In VEE that syntax is not valid so you do
xl.Workbooks.Worksheets.Add("my last sheet",2);
This is probably a bad example because there is a bug with the Add method.
Just ignore the "After" term and it is correct. Basically you can't specify
"After".

2)  How could one know that Autuor is a property of ActiveWorkbook?  How can
I find out what other properties ActiveWorkbook might contain?
ActiveWorkbook Property:
ActiveWorkbook.Author = "Jean Selva"

I could not find Author as a property of workbook in the rightmost window as
I described before. So, the method of tracking it down goes like this:
I click help and bring up excel VB help. I click index and type Author. I
get the Author Property. I click Author Property (VB) and see that Author is
a member of Worksheets.Comments. So I access it like this:
xl.ActiveWorksheet.Comments.Author

3)  How can this be translated into VEE?
Range Property:
The following example places the value of cell A1 in cell A5.
Worksheets("Sheet1").Range("A5").Value = _
    Worksheets("Sheet1").Range("A1").Value

xl.Workbooks.WorkSheets("Sheet1").Range("A1").Value
because a Range "has a" Value, and a Range, "is a" Worksheet, and a
Worksheet "is a", Workbook, and a Workbook "is a" application.

David Paslay - Engineer
mailto:dpaslay@coinco.com
web http://www.coinco.com
Coin Acceptors Inc.
300 Hunter Ave.
St. Louis, MO 63124
---------------------------------------------------------------------
This is the "vrf" maillist, managed by Majordomo.  To send messages to
this maillist, just email to "vrf@lvld.hp.com".  Subscriptions and
unsubscriptions are done through the address "vrf-request@lvld.hp.com".
If you need details, just send a message containing the text "help"
to "vrf-request@lvld.hp.com".
---------------------------------------------------------------------

Outcomes