![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | What's inside an object? I'm a little confused about objects/collections and what's inside them. How can I determine programatically what is inside an object? Take, for example, this code fragment: Set oFSO = CreateObject("Scripting.FileSystemObject") set cDrives = oFSO.Drives I already know that I can set up a loop "for each oDrive in cDrives" but I don't know how I can look at a specific drive without going through the whole collection. The code "oDrives.Item.AvailableSpace" doesn't seem to work. Here is another example, using the Excel object: oSheet.Range("E1").EntireColumn.activate Set oFind = oExcel.Selection.find("unassigned") How can I find out what items are inside oFind? Thanks for your help! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: What's inside an object? James Watkins wrote: Quote: > I'm a little confused about objects/collections and what's inside them. > How can I find out what items are inside oFind? > That's a lot of questions. The quick answer is RTFM, that is, get the documentation and read it. There are such things as "object browsers", which allow you to see all the methods, properties and enums of an object. And, if the object's programmer used readily understandable names for the methods and properties, you could probably make out what's going on. But then, there are parameters galore, and at some point the guessing becomes pointless, and you MUST get the documentation. As for some of the specific questions, you can address any specific item in a collection by its index, i.e., ...item(2).someProperty or, in some other cases, you might be able to use an alpha index, i.e., ,,,item("A").someProperty Again, what you can get away with is dependent on what the original developer wrote into his/her code -- and for that you need to read the documentation. As far as Excel (and for that matter msWord, msIE, etc) google up "Excel Object Model". As far as scripting msXL and msWD, unless I know explicitly what I am doing I tend to use the "macro recorder". You turn it on, and go (manually) through the steps you want to script. Then you turn off the recorder, and look at the macro you have just recorded. What you see will be VBA code (Visual Basic for Applications), but that is easy enough to convert to vbScript. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: What's inside an object? "James Watkins" <james@xxxxxx> wrote in message news:%23FyA8VxcJHA.5904@xxxxxx Quote: > I'm a little confused about objects/collections and what's inside them. > How > can I determine programatically what is inside an object? Take, for > example, > this code fragment: > > Set oFSO = CreateObject("Scripting.FileSystemObject") > set cDrives = oFSO.Drives > > I already know that I can set up a loop "for each oDrive in cDrives" but I > don't know how I can look at a specific drive without going through the > whole collection. The code "oDrives.Item.AvailableSpace" doesn't seem to > work. > > Here is another example, using the Excel object: > oSheet.Range("E1").EntireColumn.activate > Set oFind = oExcel.Selection.find("unassigned") > > How can I find out what items are inside oFind? > > Thanks for your help! > http://www.microsoft.com/technet/scr..._scr_xfxi.mspx For example, to bind to a specific Drive object: http://www.microsoft.com/technet/scr..._scr_ltuf.mspx You need an object browser or documentation of the Object Model for Excel properties and methods. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #4 (permalink) |
| | Re: What's inside an object? Hi James, If you haven't tried it already, step through the code using a VBScript Editor. I'm familiar with vbsedit. It lets you set break points - and in a separate pane displays active variables. You can click into variables and peruse collection members and see available Subs and Functions. Regarding the oFind object that you asked about - you might get a grip on its contents, then you might not. vbsedit can't format or figure out everything. Your question is not really a VBScript question. It's a VBA question and you could post at microsoft.public.excel.programming and ask there. Selections are pretty common - so don't be surprised if you get a few useless responses because it's obvious you don't have a clue about VBA. (I'm just saying - no offense meant.) I'm guessing the result is an a selected range having the name "unassigned". If you know for a fact that something is in that selection experimenting with : t = oFind.Cell(1,1).value t = oFind.Cells(1,1).value t = oFind.ActiveOffset(0,0).value One of these should work - *if* the selection has data. But YMMV. On Jan 10, 3:20*am, "James Watkins" <ja...@xxxxxx> wrote: Quote: > I'm a little confused about objects/collections and what's inside them. How > can I determine programatically what is inside an object? Take, for example, > this code fragment: > > Set oFSO = CreateObject("Scripting.FileSystemObject") > set cDrives = oFSO.Drives Quote: > > I already know that I can set up a loop "for each oDrive in cDrives" but I > don't know how I can look at a specific drive without going through the > whole collection. The code "oDrives.Item.AvailableSpace" doesn't seem to > work. > > Here is another example, using the Excel object: > oSheet.Range("E1").EntireColumn.activate > Set oFind = oExcel.Selection.find("unassigned") > > How can I find out what items are inside oFind? > > Thanks for your help! |
My System Specs![]() |
| | #5 (permalink) |
| | Re: What's inside an object? "James Watkins" <james@xxxxxx> wrote in message news:#FyA8VxcJHA.5904@xxxxxx Quote: > I'm a little confused about objects/collections and what's inside them. Quote: > can I determine programatically what is inside an object? Take, for Quote: > this code fragment: > > Set oFSO = CreateObject("Scripting.FileSystemObject") > set cDrives = oFSO.Drives > > I already know that I can set up a loop "for each oDrive in cDrives" but I > don't know how I can look at a specific drive without going through the > whole collection. The code "oDrives.Item.AvailableSpace" doesn't seem to > work. > > Here is another example, using the Excel object: > oSheet.Range("E1").EntireColumn.activate > Set oFind = oExcel.Selection.find("unassigned") > > How can I find out what items are inside oFind? > > Thanks for your help! > > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: What's inside an object? "James Watkins" <james@xxxxxx> wrote in message news:%23FyA8VxcJHA.5904@xxxxxx Quote: > I'm a little confused about objects/collections and what's inside them. > How > can I determine programatically what is inside an object? Take, for > example, > this code fragment: > > Set oFSO = CreateObject("Scripting.FileSystemObject") > set cDrives = oFSO.Drives > > I already know that I can set up a loop "for each oDrive in cDrives" but I > don't know how I can look at a specific drive without going through the > whole collection. The code "oDrives.Item.AvailableSpace" doesn't seem to > work. > > Here is another example, using the Excel object: > oSheet.Range("E1").EntireColumn.activate > Set oFind = oExcel.Selection.find("unassigned") > > How can I find out what items are inside oFind? > > Thanks for your help! they can be used. For example, you can only enumerate some collections with a 'for each' statement once; to go through the list again you have to get a new collection. Other collections can be enumerated multiple times. When you create collections with WMI queries, you can specify which type of collection you want. Rather than just blindly googling for info on the object you are interested in, you might want to do a more focused search. For most things Microsoft, try going to msdn.microsoft.com and do your search there. For scriptable objects, adding the two words 'object model' to things like ado or excel or word or access or dhtml or internet explorer will likely get you a shorter focused list of things to look at. The file system object is pretty well documented in the scripting help file, script56.chm. -Paul Randall |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| acquiring machine name from inside an object library | .NET General | |||
| Help "Getting an Object Inside of an Object" | PowerShell | |||
| change permission on all files inside a folder or hundreds of file inside a folder | Vista security | |||
| Testing object arrays using Compare-Object and -contains | PowerShell | |||
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | PowerShell | |||