Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing Excel Properties within VFP 1

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I am working with Tamar's very helpful book, "Microsoft Office Automation in Visual Foxpro" to read and write Excel files.

I would like to see all the properties that exist for an workbook object and for a worksheet object. Specifically I need to know how many sheets there are in a workbook so that I can open those that exist, but not get a run-time error if I try to read a non-existent work-sheet. I have an idea that this is accessible via VBA but I do not use VBA very often and have forgotten how to work with VBA in Excel.

I have tried using the VFP debugger, and can watch my object .zexcel and even a workbook which I have opened by saying :

.zWorkbook = .zExcel.Workbooks.Open(Myfilename)

But the debugger tends to run out of steam. It will tell you that something is an object but will not let you see the properties of that object unless you already know the names of them

Thanks. Andrew M.
 
Andrew,

Knowing what I know about your application and what you are trying to achieve, I'd say that's Cetin's example isn't really relevant to your problem.

This is not to detract from the information that Cetin (and Olaf) have posted. It's just that it goes well beyond the issues that you have asked about.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks Olaf for your time; I take Mike's point that this investigation may not be relevant to my original query. But the thread was of some interest, and the method of finding the constants was helpful.

Must confess that I was not able to 'browse for a DLL, OCX or EXE file of some file containing OLE classes'. Which is the Browse button? Is it the one saying Find with some exploding little squares beside it? I found that this Find Button would only work if I had already opened a particular COM brary. Or is it a matter of scanning down the list of COM libraries (as before) for a likely candidate?

I chose "Microsoft Excel 11.0 object library and got that into the top left pane of the object browser. It will display a tree of events, interfaces &c, but when I try to drag (e.g.) the activate event into the code, I just see the word 'Activate' displayed in the code window; I suspect that this was not what you meant!

Anyway, thanks again for your help.
 
Andrew,

When I said that Cetin's reply wasn't relevant to you, I wasn't referring to his advice about using the VFP Object Explorer. On the contrary, that was good advice. I was thinking of the information about using interfaces and the IMPLEMENTS clause.

Regarding dragging the nodes into a code editor, when you drag a method, event or property, you simply get its name (which still saves a bit of typing). But if you drag Interfaces (which is what Cetin was referring to), you get a complete prototype class definition, with an IMPLEMENTS clause, and the complete headers for all the methods. This can save a lot of time if you are planning on using interfaces in this way.

Another useful option is to drag any of the constants or enums. In that case, you get the #DEFINEs, exactly as you might want them in your VFP code.

On your point about not being able to open certain DLLs or EXEs in the explorer, I think the reason is that they need an accompanying type library file (extension TBR, I think). It's up to the person who creates the DLL or EXE whether they create and distribute the type library.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Do you see object browser window and Excel with a + to its left? Click that + and it would expand showing:
+Classes
+Constants
+Enums
+Events
+Interfaces
+Methods
+Properties

Now if you drag & drop that "Constants" node on to a code window you get all Excel constants. You would need it if you would do Excel automation. Save as Excel.h for later use with #include (ie: in every Excel automation code add it to top:

#include excel.h

Then, expand Interfaces node clicking + to its left. Locate AppEvents, drag&drop to a code window.


Cetin Basoz
MS Foxpro MVP, MCP
 
Thanks Cetin. Starting from the Microsoft Excel 1.0 Object Library, that works and does indeed put the skeletal interface code into the code window.

I will revisit your earlier example and work through it. Thanks again for your time.

Andrew Mozley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top