Scripting Excel question

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 14 years and 2 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
hitekrednek
Posts: 7
Last visit: Thu Jan 28, 2010 6:21 am

Scripting Excel question

Post by hitekrednek »

I have a ping script developed by the wonderful support in this forum that I use everyday and it saves me a tonne of work. Thanks again JVierra.

I do have a question in regards to the scripting excel object.

During one section of the code there is a line to write a hard coded value to the cell.

objSht.Cells(1, 25).value = "Ping Status"

Then in the For loop there are 2 lines of code that write a value to the cell dependant on the outcome.

If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then objSht.Cells(intRow,25) = "OFFLINE" Else objSht.Cells(intRow,25)= "online" End If

My question is in regards to the "value" property. It is used in the line that writes "ping status" but is not included in the lines of code found in the For loop. I've tried the script taking out the .value property and it works the same. What is the advantage or requirement of using ".value"?
User avatar
rasimmer
Posts: 182
Last visit: Fri Apr 25, 2014 7:00 am

Scripting Excel question

Post by rasimmer »

JVierra,

I was going guess that it was the default property of .Cells, but couldn't find it in MSDN for .Cells. Anyway, isn't that what Visual Studio boastssuggests "strongly-typed" code for, to eliminate "doubt"? To add to your answer in that case, would it be safe to say that not specifying the property (.value) would be like using a shortcut in the code? It works, but it's not specific and could cause issues later.
This topic is 14 years and 2 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked