Page 5 of 6 FirstFirst ... 3456 LastLast
Results 41 to 50 of 52

Thread: ब्लॉग कोशिश कर रहा है بلاگز کی ک*Trying Blogs

  1. #41
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10

    Excel File (range) SaveAs .htm ( Publish Excel Range )

    Excel File (range) SaveAs .htm

    As noted in the previous post, we can simply save an existing Microsoft Word or Excel file with the extension .htm
    For a Word file there is not much more to it than that: the entire file is saved in a HTML code format, ( https://tinyurl.com/yash9gta
    SaveAs Word.JPG Save As Word doc to htm.JPG https://imgur.com/h7XFAQX , https://imgur.com/vhRE9CC
    )

    In this post , the case of an Excel file saved as .htm format is considered. In this case, if a range is selected before the SaveAs .htm, then at the Save action , an additional dialogue box comes up.
    Consider us saving the header range:
    Using Excel 2007 32 bit
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    2
    Machine EQ.ID
    Manufacture
    Model
    Description
    Serial Number
    Weekly
    Date of Service
    Weekly
    Next Service
    Monthly
    Date of Service
    Monthly
    Next Service
    Quarterly
    Date of Service
    Quarterly
    Next Service
    Worksheet: Equipment PM

    SaveAs.jpg : https://imgur.com/ISfW7tH
    SaveAshtm.jpg: https://imgur.com/muyoVqQ

    After selecting .htm and Save for an Excel File, another Dialogue box pops up.
    ExcelDialogueBoxRangeSelect htm.JPG : https://imgur.com/14iF2SM
    At this point no file has been saved. One can see that one can choose to just save the selected Range, in this case, 'Equipment PM'!$A$2:$K$2

    On attempting to save a second time, another Dialogue box pops up , which I don’t quite understand, _...
    PublishExcelRange.JPG : https://imgur.com/6b5TV9j
    _.. but on hitting Publish, the File appears to be saved:
    SavedExcel htm.JPG : https://imgur.com/WapD7Sa
    _.....

    Examining saved htm file
    A noted, such a file can be directly sent as the main body of an Email sent. This is commonly done.
    I prefer not to do that.

    My way of doing this is to examine the file and look for the relevant HTML coding which I need. In this case I need information about that spreadsheet range 'Equipment PM'!$A$2:$K$2

    To simply examine the file, I open it with a simple text editor, ( and for convenience save it as such also )
    RightClickOn htmFile OpenWithTextEditor.JPG : https://imgur.com/OpKEf8o
    SaveAs txt File.JPG : https://imgur.com/ab1gXN8
    Saved as Txt File.jpg. : https://imgur.com/ohhQ7td
    Here is that File : “Equipment- Maint Records A2-K2 Header.txt” : https://app.box.com/s/uk3qnvuxizm10bvwoye1epg2zi1fs8qz

    I am not an HTML expert, but with a bit of common sense , I start examining the code and looking for info relevant to an 11 cell row, A2-K2

    This part looks promising:
    HTML Code:
    <tr class=xl18712769 height=64 style='mso-height-source:userset;height:48.0pt'>
      <td height=64 class=xl18312769 width=80 style='height:48.0pt;width:60pt'>Machine
      EQ.ID</td>
      <td class=xl18412769 width=207 style='width:155pt'>Manufacture</td>
      <td class=xl18512769 width=113 style='border-left:none;width:85pt'>Model</td>
      <td class=xl18612769 width=143 style='border-left:none;width:107pt'>Description</td>
      <td class=xl18512769 width=158 style='width:119pt'>Serial Number</td>
      <td class=xl19012769 width=115 style='border-left:none;width:86pt'>Weekly
        <span style='mso-spacerun:yes'> </span>Date of Service</td>
      <td class=xl19012769 width=97 style='border-left:none;width:73pt'>Weekly
        <span style='mso-spacerun:yes'> </span>Next Service<span
      style='mso-spacerun:yes'> </span></td>
      <td class=xl19112769 width=154 style='border-left:none;width:116pt'>Monthly
        Date of Service</td>
      <td class=xl19112769 width=154 style='border-left:none;width:116pt'>Monthly
      
        Next<span style='mso-spacerun:yes'>  </span>Service</td>
      <td class=xl18812769 width=161 style='border-left:none;width:121pt'>Quarterly
        Date of Service</td>
      <td class=xl19312769 width=161 style='width:121pt'>Quarterly 
        Next Service</td>
    Information that looks like it might be relevant is
    _ The reference to widths
    80
    207
    113
    143
    158
    115
    97
    154
    154
    161
    161

    _ The reference to a “class”. If I look further in the code then I can glean some info about the background colour associated with those “classes” .
    Class info in HTML text file.JPG : https://imgur.com/JmZdzmx
    So this looks like the final 11 cell (column) information that could be relevant:
    80
    207 #D8D8D8
    113
    143 #D8D8D8
    158
    115 #92D050
    97 #92D050
    154 yellow
    154 yellow
    161 #D8D8D8
    161 #D8D8D8


    _._____________


    Modifying code for Formatted header
    Currently no header is included in the sent HTML string.
    So it is convenient to construct a header manually as an addition to the start of the HTML string to be .Sended

    This will be done in the next post
    Last edited by DocAElstein; 06-13-2018 at 02:22 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  2. #42
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10

    Simple HTML code string for a header table incl. background colour

    Simple HTML code string for a header table incl. background colour

    We want a string to send as the .htmlbody in our code which will produce something of this form:
    Machine EQ.ID
    Manufacture
    Model
    Description
    Serial Number
    Weekly
    Date of Service
    Weekly
    Next Service
    Monthly
    Date of Service
    Monthly
    Next Service
    Quarterly
    Date of Service
    Quarterly
    Next Service
    Worksheet: Equipment PM
    Lets say we put this in a sting variable, strHeader

    The current String, held in variable strHTML already contains the data to be sent for that table, held in variable, ProTble.
    Code:
         Dim strHTML As String: Let strHTML = ProTble
    So we simply can add our header then finally via
    __Let strHTML = strHeader + ProTble

    From the last post, we have the following information for column width and background color
    80
    207 #D8D8D8
    113
    143 #D8D8D8
    158
    115 #92D050
    97 #92D050
    154 yellow
    154 yellow
    161 #D8D8D8
    161 #D8D8D8

    Correspondingly from the Excel range we see the header text and so have
    80 EQ.ID
    207 #D8D8D8 Manufacture
    113 Model
    143 #D8D8D8 Description
    158 Serial Number
    115 #92D050 Weekly
    97 #92D050 Weekly Nxt
    154 yellow Monthly
    154 yellow Monthly Nxt
    161 #D8D8D8 Quarterly
    161 #D8D8D8 Quarterly Nxt



    Here is a basic HTML code string for the required table, ( The vbCrLf :are not needed and are ignored by any interpreting of the HTML string. We have them for convenience of viewing the code in an editor such as a simple Notepad text file. Also the _ _ _ are just for VBA code splitting of code lines, for convenience of viewing in VB Editors )
    HTML Code:
    ' Table start column info
    Let strHeader  = "<table width=1623>" & vbCrLf & _
    "<col width=80>" & vbCrLf & _
    "<col width=207>" & vbCrLf & _
    "<col width=113>" & vbCrLf & _
    "<col width=143>" & vbCrLf & _
    "<col width=158>" & vbCrLf & _
    "<col width=115>" & vbCrLf & _
    "<col width=97>" & vbCrLf & _
    "<col width=154>" & vbCrLf & _
    "<col width=154>" & vbCrLf & _
    "<col width=161>" & vbCrLf & _
    "<col width=161>" & vbCrLf & vbCrLf
    ' single header row
    Let strHeader  =  strHeader  & _
    "<tr height=17>" & vbCrLf & _
    "<td> EQ.ID </td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Manufacture </td>" & vbCrLf & _
    "<td> Model </td>" & vbCrLf & _
    "<td style=""color:Black; background:#D8D8D8""> Description </td>" & vbCrLf & _
    "<td> Serial Number </td>" & vbCrLf & _
    "<td style=""background:#92D050""> Weekly </td>" & vbCrLf & _
    "<td style=""background:#92D050""> Weekly Nxt </td>" & vbCrLf & _
    "<td style=""background:yellow""> Monthly </td>" & vbCrLf & _
    "<td style=""background:yellow""> Monthly Nxt </td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Quarterly </td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Quarterly Nxt </td>" & vbCrLf & _
    "</tr>"
    _.______

    Results:
    The initial results suggest that a bit of adjustments are necessary to get a convenient total width
    InitialHeader gmail.JPG : https://imgur.com/D3xsfnu
    InitialHeader t-online.JPG : https://imgur.com/QK68KcS


    One possible simple way to do this adjustment is included in the final initial test code:
    Code:
    Rem 4.5) header row as HTML table
    Dim strHeader As String, Adj As Double: Let Adj = 0.5
    ' 4.5a) Table start column info
    Let strHeader = "<table width=" & 1623 * Adj & ">" & vbCrLf & _
    "<col width=" & 80 * Adj & ">" & vbCrLf & _
    "<col width=" & 207 * Adj & ">" & vbCrLf & _
    "<col width=" & 113 * Adj & ">" & vbCrLf & _
    "<col width=" & 143 * Adj & ">" & vbCrLf & _
    "<col width=" & 158 * Adj & ">" & vbCrLf & _
    "<col width=" & 115 * Adj & ">" & vbCrLf & _
    "<col width=" & 97 * Adj & ">" & vbCrLf & _
    "<col width=" & 154 * Adj & ">" & vbCrLf & _
    "<col width=" & 154 * Adj & ">" & vbCrLf & _
    "<col width=" & 161 * Adj & ">" & vbCrLf & _
    "<col width=" & 161 * Adj & ">" & vbCrLf & vbCrLf
    ' 4.5b) Single header row
    Let strHeader = strHeader & _
    "<tr height=17>" & vbCrLf & _
    "<td>EQ. ID</td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Manufacture </td>" & vbCrLf & _
    "<td>Model</td>" & vbCrLf & _
    "<td style=""color:Black;background:#D8D8D8"">Description</td>" & vbCrLf & _
    "<td>Serial Number</td>" & vbCrLf & _
    "<td style=""background:#92D050"">Weekly</td>" & vbCrLf & _
    "<td style=""background:#92D050"">Weekly Next</td>" & vbCrLf & _
    "<td style=""background:yellow"">Monthly</td>" & vbCrLf & _
    "<td style=""background:yellow"">Monthly Next</td>" & vbCrLf & _
    "<td style=""background:#D8D8D8"">Quarterly</td>" & vbCrLf & _
    "<td style=""background:#D8D8D8"">Quarterly Next</td>" & vbCrLf & _
    "</tr>"
    The following results are then obtained
    HalfWidthHeader t-online.JPG : https://imgur.com/Gup4W9t
    HalfWidthHeader gmail.JPG : https://imgur.com/PpWtDKM
    Last edited by DocAElstein; 06-13-2018 at 04:49 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  3. #43
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Simple HTML code string for a header table incl. background colour

    We want a string to send as the .htmlbody in our code which will produce something of this form:
    Machine EQ.ID
    Manufacture
    Model
    Description
    Serial Number
    Weekly
    Date of Service
    Weekly
    Next Service
    Monthly
    Date of Service
    Monthly
    Next Service
    Quarterly
    Date of Service
    Quarterly
    Next Service
    Worksheet: Equipment PM
    Lets say we put this in a sting variable, strHeader

    The current String, held in variable strHTML already contains the data to be sent for that table, held in variable, ProTble.
    Code:
         Dim strHTML As String: Let strHTML = ProTble
    So we simply can add our header then finally via
    __Let strHTML = strHeader + ProTble

    From the last post, we have the following information for column width and background color
    80
    207 #D8D8D8
    113
    143 #D8D8D8
    158
    115 #92D050
    97 #92D050
    154 yellow
    154 yellow
    161 #D8D8D8
    161 #D8D8D8

    Correspondingly from the Excel range we see the header text and so have
    80 EQ.ID
    207 #D8D8D8 Manufacture
    113 Model
    143 #D8D8D8 Description
    158 Serial Number
    115 #92D050 Weekly
    97 #92D050 Weekly Nxt
    154 yellow Monthly
    154 yellow Monthly Nxt
    161 #D8D8D8 Quarterly
    161 #D8D8D8 Quarterly Nxt



    Here is a basic HTML code string for the required table, ( The vbCrLf :are not needed and are ignored by any interpreting of the HTML string. We have them for convenience of viewing the code in an editor such as a simple Notepad text file. Also the _ _ _ are just for VBA code splitting of code lines, for convenience of viewing in VB Editors )
    HTML Code:
    ' Table start column info
    Let strHeader  = "<table width=1623>" & vbCrLf & _
    "<col width=80>" & vbCrLf & _
    "<col width=207>" & vbCrLf & _
    "<col width=113>" & vbCrLf & _
    "<col width=143>" & vbCrLf & _
    "<col width=158>" & vbCrLf & _
    "<col width=115>" & vbCrLf & _
    "<col width=97>" & vbCrLf & _
    "<col width=154>" & vbCrLf & _
    "<col width=154>" & vbCrLf & _
    "<col width=161>" & vbCrLf & _
    "<col width=161>" & vbCrLf & vbCrLf
    ' single header row
    Let strHeader  =  strHeader  & _
    "<tr height=17>" & vbCrLf & _
    "<td> EQ.ID </td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Manufacture </td>" & vbCrLf & _
    "<td> Model </td>" & vbCrLf & _
    "<td style=""color:Black; background:#D8D8D8""> Description </td>" & vbCrLf & _
    "<td> Serial Number </td>" & vbCrLf & _
    "<td style=""background:#92D050""> Weekly </td>" & vbCrLf & _
    "<td style=""background:#92D050""> Weekly Nxt </td>" & vbCrLf & _
    "<td style=""background:yellow""> Monthly </td>" & vbCrLf & _
    "<td style=""background:yellow""> Monthly Nxt </td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Quarterly </td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Quarterly Nxt </td>" & vbCrLf & _
    "</tr>"
    _.______

    Results:
    The initial results suggest that a bit of adjustments are necessary to get a convenient total width
    InitialHeader gmail.JPG : https://imgur.com/D3xsfnu
    InitialHeader t-online.JPG : https://imgur.com/QK68KcS


    One possible simple way to do this adjustment is included in the final initial test code:
    Code:
    Rem 4.5) header row as HTML table
    Dim strHeader As String, Adj As Double: Let Adj = 0.5
    ' 4.5a) Table start column info
    Let strHeader = "<table width=" & 1623 * Adj & ">" & vbCrLf & _
    "<col width=" & 80 * Adj & ">" & vbCrLf & _
    "<col width=" & 207 * Adj & ">" & vbCrLf & _
    "<col width=" & 113 * Adj & ">" & vbCrLf & _
    "<col width=" & 143 * Adj & ">" & vbCrLf & _
    "<col width=" & 158 * Adj & ">" & vbCrLf & _
    "<col width=" & 115 * Adj & ">" & vbCrLf & _
    "<col width=" & 97 * Adj & ">" & vbCrLf & _
    "<col width=" & 154 * Adj & ">" & vbCrLf & _
    "<col width=" & 154 * Adj & ">" & vbCrLf & _
    "<col width=" & 161 * Adj & ">" & vbCrLf & _
    "<col width=" & 161 * Adj & ">" & vbCrLf & vbCrLf
    ' 4.5b) Single header row
    Let strHeader = strHeader & _
    "<tr height=17>" & vbCrLf & _
    "<td>EQ. ID</td>" & vbCrLf & _
    "<td style=""background:#D8D8D8""> Manufacture </td>" & vbCrLf & _
    "<td>Model</td>" & vbCrLf & _
    "<td style=""color:Black;background:#D8D8D8"">Description</td>" & vbCrLf & _
    "<td>Serial Number</td>" & vbCrLf & _
    "<td style=""background:#92D050"">Weekly</td>" & vbCrLf & _
    "<td style=""background:#92D050"">Weekly Next</td>" & vbCrLf & _
    "<td style=""background:yellow"">Monthly</td>" & vbCrLf & _
    "<td style=""background:yellow"">Monthly Next</td>" & vbCrLf & _
    "<td style=""background:#D8D8D8"">Quarterly</td>" & vbCrLf & _
    "<td style=""background:#D8D8D8"">Quarterly Next</td>" & vbCrLf & _
    "</tr>"
    The following results are then obtained
    HalfWidthHeader t-online.JPG : https://imgur.com/Gup4W9t
    HalfWidthHeader gmail.JPG : https://imgur.com/PpWtDKM
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  4. #44
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Test

    [QUOTE=PG CodeRider]jdyjd[/Q
    UOTE]


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=318868#p318868
    https://eileenslounge.com/viewtopic.php?p=318311#p318311
    https://eileenslounge.com/viewtopic.php?p=318302#p318302
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317857#p317857
    https://eileenslounge.com/viewtopic.php?p=317541#p317541
    https://eileenslounge.com/viewtopic.php?p=317520#p317520
    https://eileenslounge.com/viewtopic.php?p=317510#p317510
    https://eileenslounge.com/viewtopic.php?p=317547#p317547
    https://eileenslounge.com/viewtopic.php?p=317573#p317573
    https://eileenslounge.com/viewtopic.php?p=317574#p317574
    https://eileenslounge.com/viewtopic.php?p=317582#p317582
    https://eileenslounge.com/viewtopic.php?p=317583#p317583
    https://eileenslounge.com/viewtopic.php?p=317605#p317605
    https://eileenslounge.com/viewtopic.php?p=316935#p316935
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317014#p317014
    https://eileenslounge.com/viewtopic.php?p=316940#p316940
    https://eileenslounge.com/viewtopic.php?p=316927#p316927
    https://eileenslounge.com/viewtopic.php?p=316875#p316875
    https://eileenslounge.com/viewtopic.php?p=316704#p316704
    https://eileenslounge.com/viewtopic.php?p=316412#p316412
    https://eileenslounge.com/viewtopic.php?p=316412#p316412
    https://eileenslounge.com/viewtopic.php?p=316254#p316254
    https://eileenslounge.com/viewtopic.php?p=316046#p316046
    https://eileenslounge.com/viewtopic.php?p=317050&sid=d7e077e50e904a138c794e1f2115da95#p317050
    https://www.youtube.com/@alanelston2330
    https://www.youtube.com/watch?v=yXaYszT11CA&lc=UgxEjo0Di9-9cnl8UnZ4AaABAg.9XYLEH1OwDIA35HNIei0z-
    https://eileenslounge.com/viewtopic.php?p=316154#p316154
    https://www.youtube.com/watch?v=TW3l7PkSPD4&lc=UgwAL_Jrv7yg7WWC8x14AaABAg
    https://teylyn.com/2017/03/21/dollarsigns/#comment-191
    https://eileenslounge.com/viewtopic.php?p=317050#p317050
    https://eileenslounge.com/viewtopic.php?f=27&t=40953&p=316854#p316854
    https://www.eileenslounge.com/viewtopic.php?v=27&t=40953&p=316875#p316875
    https://eileenslounge.com/viewtopic.php?p=316057#p316057
    https://eileenslounge.com/viewtopic.php?p=315915#p315915
    https://eileenslounge.com/viewtopic.php?p=316705#p316705
    https://eileenslounge.com/viewtopic.php?p=316704#p316704
    https://eileenslounge.com/viewtopic.php?p=176255#p176255
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 07-27-2024 at 01:42 PM.

  5. #45
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10

    Named Ranges: Name and object string reference .Value

    Copy of Reply to this:
    https://www.thespreadsheetguru.com/b...ent-4082118270

    Quote Originally Posted by PG CodeRider
    ... to scope a workbook in a named range , best syntax is: ThisWorkbook.Names("YourName").RefersToRange.

    Using ThisWorkbook.Range("YourName") will not work!
    @ PG CodeRider. Hi!
    _1) I’m not familiar with a syntax like ThisWorkbook.Names("YourName").RefersToRange.___ So I am not quite completely sure what you are saying. Can you clarify a bit please, thanks.
    _2) & _3) :- These couple of points might be relevant somehow to the issue you are talking about

    _Point 2).
    This sort of thing, ThisWorkbook.Names("YourName").____ , I would expect would “do something sensible” as it will return a Name object. So then, to that Name object you could , for example , apply the Name property, and so , for example, rename the Named Range object. ( see '2(ii) in my demo code below).
    In addition, it seems that the named Range object is one of those objects which if you “use” the object in a code part where a string is expected, rather than an object, then , instead of erroring with type mismatch as you might at first expect, a different phenomena occurs: In such a “usage” it actually “gives you” some string reference. In the case of a named Range, what it “gives you” appears to be the string reference of the range to which the Named Range refers, (see '2(iii)a) in my demo code below). You can use this strange phenomena then to actually change the referred to range , (see '2(iii)b) in my demo code below).
    (This phenomena might be something to do with that the .Value property is usually the default property for an object)

    _Point 3) I would not expect something like ThisWorkbook.Range("YourName") to ever “work” in most circumstances. The reason for this. I think, is simply that there is no Range property of a workbook.
    As far as I know the main range “things” are the Worksheet range property and the Application Range “thing”. ( The latter is often called a property, but I sometimes think of it as a Method.. or “thing” )
    In Rem _Point 3) of my demo code below I look at these ways of getting at a named range.
    So, for example, something of this form ThisWorkbook.Application.Range(YourName").____ will usually “do something sensible”. For example, '3)(ii)b) and '3)(ii)c) in my demo code below is a version of what I call the “short hand way” of making a workbooks scope Named Range.
    ( I don’t think I can do anything similar to '2(iii)b) via the range things to actually change the referred to range , as I guess that might cause a chaos …. Maybe…. )
    _.________________
    If you want to try my demo routine below, Sub ObjRefValueWonkEtc() , make sure you also copy the other two routines, so three in total.

    Alan


    Code:
    Sub ObjRefValueWonkEtc() ' https://www.thespreadsheetguru.com/blog/the-vba-guide-to-named-ranges#comment-4082118270
    Rem 0) Clean the sheet of names
     Call FukOffNames
     Call getWbNames
    Rem _Point 2) Name Object Names and Name string range references
    '2(i) Add a Named range name object with workbook scope
     ThisWorkbook.Names.Add Name:="YourFirstName", RefersTo:=ActiveSheet.Range("B1")
     Call getWbNames
    '2(ii) Use .Name property to change the name
     Let ThisWorkbook.Names("YourFirstName").Name = "YourSecondName" ' Change name using name property of Name object
     Call getWbNames
    Dim objYourName As Object: Set objYourName = ThisWorkbook.Names("YourSecondName") ' use an object variable for the Name object
     Call getWbNames
     Let objYourName.Name = "YourThirdName" ' Change name using Name property of Name object again, ( using the object variable this time )
     Call getWbNames
    ' Check info
    '2(iii)a)
     MsgBox prompt:="You last name for the cell B1 was  """ & objYourName.Name & """" & vbCrLf & "and if you ""use"" that object where a string is expected like here in this MsgBox, then you get a reference looking like this:  " & """" & objYourName & """"
    '2(iii)b) use the string ""Value" property" to change the refered to range reference
     Let objYourName.Value = "=" & ActiveSheet.Name & "!$B$2" ' give the typical full range reference for a cell
     Call getWbNames
    Dim strRef As String: Let strRef = objYourName ' this defaults probably to the next line
     Let strRef = objYourName.Value
    Rem _Point 3) Use range to access a Named Range
    '3)(i) use Worksheets range property
     Let ActiveSheet.Range(strRef).Value = "Allo4"
    ' Let Worksheets.Item(1).Range(strRef).Value = "Allo5" ' This will only work if the Named Range is in, that is to say, refers to, the first worksheet
    ' Let Worksheets.Item("NamedRanges").Range(strRef).Value = "Allo6" ' This will only work if the Named Range is in, that is to say, refers to, the worksheet with tab Name "NamedRanges"
    '3)(ii)a) Use Application.Range "thing" to get at the named range
     Let ThisWorkbook.Application.Range("YourThirdName").Value = "Allo1"
     Let ThisWorkbook.Application.Range(strRef).Value = "Allo2"
     Let strRef = Replace(strRef, "$B$2", "YourThirdName") ' replace the cell address with the name we last gave that cell
     Let ThisWorkbook.Application.Range(strRef).Value = "Allo3"
     Let Application.Range("=" & "'" & ThisWorkbook.Path & "\" & "[" & ThisWorkbook.Name & "]" & ActiveSheet.Name & "'" & "!" & "YourThirdName").Value = "Allo7" ' Just for fun to demo that Application.Range(" ") syntax will accept a full reference
    '3)(ii)b) Give another names to an existing Named Range using "short hand way"
     Let ThisWorkbook.Application.Range(strRef).Name = "YourforthName" ' Note this adds another name, it does not replace the existing one
     Let ThisWorkbook.Application.Range(ActiveSheet.Name & "!" & "YourThirdName").Name = "YourfifthName"  ' Note this adds another name, it does not replace the existing one
    '3)(ii)c) Add a new named range using "short hand way"
     Let ThisWorkbook.Worksheets.Item(2).Range("G4").Name = "WorkbookScopeNamedRangeInCellG4InSecondWorksheetOfThisWorkbook"
     Call getWbNames
    Rem 4 Just for passing fun .. strange phenomena  .. the next line won't work initially _....
     Call FukOffNames: Call getWbNames
    '4a) .. strange phenomena  .. the next line won't work initially _....
     'Let ThisWorkbook.Worksheets.Item(2).Range("G5").Name.Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbook"
     ' _.... But if I do this next line first, then it will work
     Let ThisWorkbook.Worksheets.Item(2).Range("G5").Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName1"
     Call getWbNames
     Let ThisWorkbook.Worksheets.Item(2).Range("G5").Name.Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName2"
     Call getWbNames
    '4b) .. what is going on  ... attempt to explain  ,  ThisWorkbook.Worksheets.Item(2).Range("G5").Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName1"  somehow made a named range object, and gave it the name  "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName1"
    Dim objNameG5 As Name: Set objNameG5 = ThisWorkbook.Worksheets.Item(2).Range("G5").Name  ' .. as I have a name object, then I can assign an object variable to it.
     Call getWbNames
     Let objNameG5.Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName3" ' this has now given a new name to the name Object,  objNameG5
     Call getWbNames
     Let ThisWorkbook.Worksheets.Item(2).Range("G5").Name.Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName4" ' This does the same as objNameG5.Name = "WorkbookScopeNamedRangeInCellG5InSecondWorksheetOfThisWorkbookName4"
     Call getWbNames
    End Sub
    
    
    
    
    
    Sub getWbNames()
    Dim Nme As Name, Cnt As Long
        For Each Nme In ThisWorkbook.Names
         Let Cnt = Cnt + 1
        Dim strNames As String: Let strNames = strNames & Cnt & "   "
            If TypeOf Nme.Parent Is Worksheet Then ' Answer 2 - https://stackoverflow.com/questions/8656793/progammatically-determine-if-a-named-range-is-scoped-to-a-workbook
             Let strNames = strNames & """" & Nme.Name & """  refers to the range ref  """ & Nme & """  and and can be referenced only from worksheet with tab Name  """ & Nme.Parent.Name & """ ( Worksheet Scope ). ( That worksheet is in the workbook  """ & Nme.Parent.Parent.Name & """  )" & vbCrLf & vbCrLf
            Else
             Let strNames = strNames & """" & Nme.Name & """  refers to the range ref  """ & Nme & """  and can be referenced from any sheet in the Workbook  """ & Nme.Parent.Name & """  ( Workbook Scope )" & vbCrLf & vbCrLf
            End If
        Next Nme
        If strNames = "" Then
         MsgBox prompt:="I don't think you have any Names at the moment luvy"
        Else
         MsgBox prompt:=strNames, Title:="Spreadsheet Named range objects in " & ThisWorkbook.Name & " are:-"
        End If
    End Sub
    
    Sub FukOffNames()
    Dim Nme As Name
         For Each Nme In ThisWorkbook.Names
          Nme.Delete
         Next Nme
    End Sub

    Edit: I added Rem 4 just to the post here at excelfox for fun as I have more space, and the code 'comments go to the right , so the code looks less cluttered
    _.___________________
    Edit 2 ...… a few hours later… after answering a few comments at the blog ( https://www.thespreadsheetguru.com/b...o-named-ranges ) I understand now what you PG CodeRider means by “….to scope a workbook in a named range , best syntax is: ThisWorkbook.Names("YourName").RefersToRange….”
    I see now that if I have an existing Named range with the name , "YourName" , then something like this will change the range it refers to
    ThisWorkbook.Names("YourName").RefersToRange = "=Sheet1!$A$1"
    So that answers my first question, 1)
    _.________
    Something like this will also work
    Range("=Sheet1!$A$1").Name = "YourName"
    The first time you use that, a Name object with the string name "YourName" is made if it does not already exist. ( It has workbooks scope and refers to the range $A$1 in Sheet1). Once it exists, then code lines like this will work to change the range it refers to, or its string Name

    Application.Range("=Sheet1!$A$1").Name.RefersTo = "=Sheet1!$X$700"
    Application.Range("YourName").Name.RefersTo = "=Sheet2!$A$100"
    Application.Range("=Sheet2!$A$100").Name.RefersTo = "=Sheet3!$A$100"
    Application.Range("YourName").Name.Name = "YourNewName"


    I refer to a code line like Range("=Sheet1!$A$1").Name = "YourName" as a shorthand way to make a workbook scoped Named range. It is quite curious how/ why it works. I am not sure that I understand exactly how/ why it works. … Initially this, Range("=Sheet1!$A$1").Name , is returning a name object, not a name string. But a named range seems to be one of those objects which returns a reference string if you use the object variable in a place where a string is given or expected. Also I note that the default property of a lot of objects is .Value. I find that if I apply the .Value property to a Name object, then I get the same as if I apply the . RefersTo property. Somehow the result of all this is that a code line like Range("=Sheet1!$A$1").Name = "YourName" seems to make a named range object and give it the string name of "YourName”
    Last edited by DocAElstein; 11-09-2018 at 09:52 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  6. #46
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10

    Computer Updates List

    Windows Update List
    .
    This post is in support of this forum question answer:
    http://www.eileenslounge.com/viewtopic.php?f=21&t=31572

    A problem was encountered with a solutions previously used successfully on computers to produce a simple text file containing a list of all Windows updates. The solution was successful previously for computers with Operating systems Vista and Windows 7.
    ( http://www.excelfox.com/forum/showth...0582#post10582 )
    The problem was that it appeared not to work for operating system XP.

    The most important part of this solution that I present here is a free software, wul , from a person called Nir Sofer
    https://www.nirsoft.net/utils/wul.html
    http://launcher.nirsoft.net/downloads/index.html

    In this Thread I may refer to this software, and/or results from it, as Wul , WinUpdatesList , WinUpdatesList software from NirSoft , or the wul stuff … etc.
    This software from Nir Sofer does all the important stuff. My contribution is just to make it a bit more convenient to use specifically as I need , which is to allow me to compare the updates in different computers
    The following posts walk through and explain the complete solution that I am using.

    Download software and store in Folder
    The software is downloaded to anywhere, and the entire contents of the Zip folder copied and pasted to a folder of choice, I use a Folder with the name Udates – The way this works for me is to simply select the entire Zip Folder contents, copy using Ctrl+c ( or by selecting the option from the selection given by clicking on the right mouse), and then in the clicking anywhere in the folder Updates and doing Ctrl+v , ( or selecting the insert or similar option from the selection given by clicking on the right mouse)
    Copy Paste nirsoft wul.JPG : https://imgur.com/kuA67zm

    Get HTML file WinUpdatesList __ HTML Report – All Items
    Double click on wul.exe , and in the Window ( WinUpdatesList MYCOMPUTER ) , that should come up, select the icon to make a HTML copy.
    HTML Report - All Items .JPG : https://imgur.com/OQRzvrZ
    This will make a HTML file which is placed in the same folder as wul.exe. This HTML file can be read by some things to produce the output , which you may see automatically on a currently opened browser. This may depend on your own Browser and Browser settings. I use Google Chrome with standard settings, and I find that if my browser is opened when I select the icon to make a HTML copy, then in addition to the html file appearing in folder Updates, I also see a newly opened tab in my browser as shown in this screenshot below:
    HTML report.JPG : https://imgur.com/DgbjPSg

    What to do with that HTML file
    My contribution is simply the manipulation of that HTML file.
    I have a couple of possibilities. The simplest of which would be to just open that HTML file with a simple text editor, and re save that as a text, .txt , file. I could then use some VBA coding to take in that text along with some further VBA string manipulation code to get a Listing in some convenient form to read or further use, such in comparison with lists from different computers.

    I have a possibility to do something slightly more advanced with HTML type things. This will allow me to then do the simplest thing mentioned above in a slightly more round about sort of a way, but also more usefully , I can do manipulation with the HTML string, taken as a pseudo “object” which allows me to do something equivalent to what would have been the string text manipulation, but I can do it in terms of using Properties and Methods of the “pseudo” object. ( As the concept of the object in VBA is itself somewhat imprecise, we can refer to a “pseudo” object and object as meaning the same for our purposes ).
    I will describe briefly the adaptation of the Later that I will do, and give some reference to the ' code sections in the routine that I actually present ( http://www.excelfox.com/forum/showth...0896#post10896
    http://www.excelfox.com/forum/showth...0897#post10897
    http://www.excelfox.com/forum/showth...0898#post10898
    )

    Rem 2 Building a “HTML object thingy” from the HTML file
    This is generally seen done in the following way.
    Objects from two different types/classes are used. ( Typically we talk about .. '2a XML requesting and '2b HTML Document object )
    '2a Getting a long string of HTML coding
    '2a usually uses something that has to do with HTML things and strings moving about. This is usually used for trying to get things around the internet, but as this HTML stuff is a sort of computer language used to make things on a screen in front of us that we can see in a meaningful form, then a HTML file can often be indistinguishable to some computer things from some large HTML string code floating around the Internet. That explains why we may see something in our internet browser if it is open, in addition to the window created specifically from the software wul. The browser will be basically reading meaningfully a form of the HTML file.
    I am not sure if in this case that should happen, or it is an accident that the HTML file moving around our computer is “caught” by the browser as something that it might have considered to be coming from the internet. In any case , in '2a the xmlHTTP stuff object coming from a , MSXML2 , ( “Microsoft XML Passer” thing http://www.eileenslounge.com/viewtop...=31547#p244184 ) type/class library thing is the object used to get our HTML string. As far as I know that is a simple string of text. That will have mostly text characters including a lot of pointy brackets in it that we can see as well as things like Line feeds and carriage returns , so that it will be displayable if we open it in any typical text editor. There maybe other things in it which I am not aware of….. but if there are , I doubt there are many. So at the end of code section '2a we will have something that we could see in its raw form as the following. ( Something such as an Internet Browser, would recognise that as coding and produce the earlier screenshots ( HTML report.JPG : https://imgur.com/DgbjPSg )
    Report as txt and HTML.JPG : https://imgur.com/mfsrXMN
    Here are the files from that last screen shot . ( The .txt File is produced by saving that seen text file as report.txt instead of the seen report.html. ( If you down load those files and try to open them by simply double clicking on them, then there is a good chance that at least one of them might open somehow. It will depend a lot on what software you have and what settings you may have.)
    report.html : : https://app.box.com/s/u3f885u8og1hfjed4npkgllyptyfc7dp
    report.txt : https://app.box.com/s/u3f885u8og1hfjed4npkgllyptyfc7dp

    '2b DOM stuff' Make OOP type model of HTML code, using Microsoft HTML Office Library
    This basically takes in the string from '2a into an object of type/class with a name of htmlfile ( late Binding ) or HTMLDocument ( Early Binding )
    At this stage we have an object made from the HTML coding stringto which we can apply various properties to manipulate indirectly the HTML coding string. In addition we have that simply string from '2a and could also do more direct manipulation of that.

    So the next post will look at manipulation, primarily of the made OOP type model object, ( HTMLdoc ) , to give us a simple list of our updates.
    Last edited by DocAElstein; 01-09-2019 at 09:37 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  7. #47
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Manipulation of string Directly and Indirectly
    For now, I will mostly concentrate in this post on the indirect way of manipulation , that is to say through the use of the OOP type model object, ( HTMLdoc ). I will just briefly touch initially on looking at the simple string as a string of text..

    Rem 3 Manipulation of string Directly and Indirectly
    Rem 3a) Directly
    I have not completed this section yet. I may come back to this later. The only thing I have done is to produce a simple text file from the HTML code string , PageSrc , which was obtained from '2a
    Just for fun, if we compare the two text files, report.txt and the text file made in this section, strTextFile.txt then we see that they appear very similar.. in fact they appear to be the same, except that their size differs…. I will definitely come back to look at that later..…. ##
    report_txt and strTextFile_txt .JPG : https://imgur.com/35eE19e
    report_txt and strTextFile_txt .JPG : https://imgur.com/0MdFeUt

    Rem 3b) (Rem 3b)(ii) ) Large Object from main made OOP type model object, ( HTMLdoc )
    This is a small “ in between “ section , which I mainly do to keep in line with a typical way of doing coding of this type.
    The OOP type model object, ( HTMLdoc ) is a large quite complicated object , which is probably difficult to relate to anything humanly perceivable. Generally we try to get at an “under object” either directly of through other objects. There probably are ways to get straight to a specific “thing” which we are after, but usually it is not done that way. If we always did that simple way, then it might put a lot of computer programmes out of work as the extra complication helps to give them something to do.
    In this short code section we use the The .getElementsByTagName( ) method, which is a method available to our created HTMLdoc . This returns a collection of all elements in the document with the specified tag name, as a “NodeList” object. A NodeList object represents a collection of nodes. The nodes can be accessed by index numbers. The index starts at 0. The nodes can crudely be considered as simply points in our long string, and generally we talk in computing about nodes as the point in a string at a branch in a string type structure. The index number would usually represent nodes of the same level that also satisfy the condition in the ( )
    This string structure can sometimes be seen in the way the indent is used in the HTML text files.
    This is all somewhat academic to the fairly simple “html string file” that we are using, but in this way we are coming close to using the same coding as for getting information from the very large ( actually very long html string ) data strong that is used to show a typical internet site.
    In our case the use .getElementsByTagName( ) has resulted in getting a collection object of just one item, ( which, incidentally , our HTMLdoc appears to have actually recognised as a table. Indeed, if we were using Early Binding, then we could of Dimed the object we use in the next section as a HTMLTable
    oTable as HTMLTable.JPG : https://imgur.com/R309JjC
    In a , ( possibly unnecessary round about sort of a way ) we finally have a “table object” , ( specifically a “html Dom objectHTMLTable ).
    _.________________________________________________ ____

    Rem 4 Manipulation of string Indirectly
    We start here probably at the main point of the use of a OOP type model object, ( HTMLdoc ) in preference to a more straight forward way of string manipulation of either our report.txt or , strTextFile.txt file or PageSrc text String .
    ( Rem 4 would probably be better denoted by Rem 3b)(ii), but the use of Rem 4 is partly because it is a large section of a particular theme, that of the manipulation ( and partly just to keep in comparison with some other coding of this type that I have ) )

    Code section '4b) Array generation from HTMLTable objects within “html Dom object”
    This code section forms the main working to get a useable list of update data. It basically fills a data array using the “html Dom object” properties for the HTMLTable object which the last section has got us.
    I will review how we got here and then go on to walk through this code section in more detail.
    Review How did we get this far.
    This review is specifically referring to the “HTML stuff and nonsense”…
    We have originally been presented with a large string of text which looks like a lot of normal everyday text except that a lot of pointy brackets are included. This string text format characterises a typical “HTML” coding, which is one of the most common languages used for things moving around the internet. In the previous code sections we have used some tried and tested techniques, principally for using information from the internet, but which work equally well for our File containing that string of “pointy bracket text”. The result of using these techniques is that we have been able to supply a form of our original text , ( possibly in fact exactly the same, I am not sure yet ## ) , held in a simple String variable, PageSrc , into an object of a type/class going by the names of HTMLDocument for Early Binding and htmlfile for late binding. ( We use late binding , and note in parsing that we are dealing with a class that untypical works slightly differently in Early and Late binding : http://www.eileenslounge.com/viewtop...=31547#p244184 ) . This large main object is often named , htmlfile , HTMLdoc , html dom object , HTML document object … or similar
    In our coding we use HTMLdoc for the variable for this main large object.
    At the start of code section Rem 4 we have used a technique typically used to allow getting at “under objects “ from the main large “Dom” object. For our simple case we end up with an object known as a HTMLTable, which in simple terms could be thought of as an actual table full just as we want finally full with our update information.

    The next detailed code description in the next post may appear more complicated than it is.
    All we are doing is using the Properties of that table to build a simple array of our data. If you are familiar with a bit of VBA , then when dealing with “HTML Dom things” , a slight adjustment in your way of thinking can be helpful:
    The properties that we use are approximately mainly to do with :

    Rows : This can be considered as similar to rows type things in VBA and Excel generally.

    Cells : In “HTML Dom things” generally and in “HTMLTable” things in particular, a regular row, column way of thinking as in a spreadsheet is not so common. It is more unusual to talk in terms of Cells. To a first approximation a Cell in a HTML Table and a spreadsheet could be considered similar. In general we do not talk in terms of column things.
    What we can have, in addition to the entire cells for the table, is an additional Cells property for each row. So rather than getting at a Cell via a (r, c) type co ordinate system as in the case of a spreadsheet, we tend to do something different for a HTML table. For a MTHM Table we would tend to refer to a cell via something like pseudo
    Table.Row(r).Cells(C)
    So as comparison: In VBA coding generally we might see like this pseudo coding to loop through a range or a table
    __For each row, r
    ____For each column, c
    As comparison the equivalent pseudo coding when looking at HTML Table coding would be like:
    __For each row, r
    ____For each row(r).cell(C)

    Length : In HTML things, the word Length is often used where in other VBA things, the word Count might be used.


    The next post will now look at a detailed walkthrough of code section 4b)
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  8. #48
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    '4b)= =Building Array from HTML Table

    There could be some erroneous / irrelevant 'comments in this particular coding as I am trying to keep iit comparable with some others that I have for web scrapping. So apologies for that. The walkthrough here should be specific for the issue at hand and approximately in line with the ' comments in the coding

    I am doing a working example using my old Acer Aspire Lap top 4810TZG with Vista Operating System. If I use the WinUpdatesList software from NirSoft whilst my Google Chrome Browser is open then a new tab appears with a table in it. If I click on that, do a Ctrl+a , followed by a Ctrl+c, then click in the first cell of a spare Excel worksheet, and finally do a Ctrl+v , than I finally get a full worksheet looking something as shown here:
    Worksheet report_html.JPG : https://imgur.com/FieBLkF
    An example is in worksheet “report_html” in this file
    WMI Query.xlsm” : https://app.box.com/s/z15s0syizlct1nufhivl2yu4iupek8pi

    In fact, that final table is more or less what I finally want. I forgot why I am trying to get that now in a complicated way, but never mind..
    That table/range comes from the html coding string file , “report.html” . That html file is what my coding uses. So observation of that Excel worksheet table/range characteristics will be useful to have when developing and explaining the current code section, '4b) , under discussion. In particular it will be helpful to note the following characteristics of that excel worksheet table/range
    _ It uses columns A-K. So we have 11 columns
    _ In total there are 953 rows used.
    _ For the actual data, rows 7 to 953 are used. So we have ( 953-7)+1 = 947 rows of data ( … that calculation comes from like say I have 10 rows of data from row 1 to row 10, then … (10-1)+1=10 )

    Note: To get this routine to work, you will need to have 2 Files in the same ( any ) Folder …._
    _... the file with the coding in it ,
    as well as _..
    _... the “report.html” file , within a folder “Updates”
    ThisWorkbook Udates report_html.JPG : https://imgur.com/3udCqdW

    The code line that requires this organisation of files is this:
    _ Let strURL = ThisWorkbook.Path & "\Updates" & "report.html"
    So if you have your coding and file organisation in some other way then you will need to adjust that code line appropriately : The full path and file name given in that line must be that of where the file "report.html" is

    Remember:
    To get that file, "report.html" , you need to run wul.exe and then select the HTML Report – All Items icon
    HTML Report - All Items .JPG : https://imgur.com/OQRzvrZ
    Re read again from here for more detail http://www.excelfox.com/forum/showth...0893#post10893

    '4b)= =Building Array from HTML Table
    '4b(i) returns us the table characteristics of
    rowCnt = 948
    colCt = 10428
    colCnt = 11

    For example, click in left margin to put stop on code, and run code, and hover over the variables with the mouse to see the contents of a variable:
    rowCnt947.JPG : https://imgur.com/jEXoHrJ

    '4b(ii) Looping through rows to build output array BASIC IDEA
    At this point it might be worth a quick glance at a more simple code such as from Pike here : ( https://www.mrexcel.com/forum/excel-...ml#post4026613 )
    Code:
     Set objTable = html.getElementsByTagName("table")
     For lngTable = 0 To objTable.Length - 1
            For lngRow = 0 To objTable(lngTable).Rows.Length – 1    '       For every  row in a table .._ 
                For lngCol = 0 To objTable(lngTable).Rows(lngRow).Cells.Length – 1 '  _.. Go along every cell in that row
                    ThisWorkbook.Sheets("Sheet2").Cells(ActRw + lngRow + 1, lngCol + 1) = objTable(lngTable).Rows(lngRow).Cells(lngCol).innerText
                Next lngCol
            Next lngRow
            ActRw = ActRw + objTable(lngTable).Rows.Length + 1
        Next lngTable
    End Sub
    My coding in section '4b is in effect doing nothing more than that. I am basically looping through all HTML Cell s and preparing from that an output. The above code pastes out each HTML Cell content to a worksheet Cell as it goes along each cell in a row of the HTML table

    My coding differs in that it first fills an array completely, which is the main purpose of '4b(ii)a - '4b(ii)b , and then finally does the pasting out in one go in '4b(ii)c.
    My coding has additionally a more complicated way to get each array element which allows for the case , ( which we don’t actually have, but never mind ) of a html table within a html table, or similar , and additionally we can do some post processing for example selectively on each column. That can be useful for example to change frequently used long text to an abbreviation to make the final table more readable.

    '4b(ii) Looping through rows to build output array. Walkthrough coding
    __Rows are looped through, and at each row
    ____the cells in each row, which are effectively the columns in a classic sense, are looped through
    All that is basically required at this point to fill our array , Data( , ) , would be a simple code line of like
    _____ Data(r, C)= oTable.Rows(r).Cells(C).innerText
    In such a code line, oTable.Rows(r).Cells(C) returns the ”HTML dom object model “ cell object, ( HTMLTableCell ) :
    HTMLTableCell object.JPG : https://imgur.com/UT66C6D
    In most simple coding the .innerText Property could be used to get the actual information that we want, for example in the first cell , we see “Name “ :
    innerText.JPG : https://imgur.com/UT66C6D
    ( This would tend to suggest that the table we have found is , in fact the actual data, rather than the final output given by the WinUpdatesList software.
    Name at top left of data.JPG : https://imgur.com/yU4jd7Z
    The discrepancy in the total number of rows, I am not sure about at this stage
    )

    Brief description of Sub GetElemsText
    ( I have this Sub GetElemsText from Leith Ross : https://www.mrexcel.com/forum/excel-...ml#post4031122 )
    You will see that I do not do the simple code line of
    _____ Data(r, C)= oTable.Rows(r).Cells(C).innerText
    The code line I do have , will in the vast majority of situations do exactly the same:
    _____Call GetElemsText(oTable.Rows(r).Cells(C), Data(r, C))
    The routine Sub GetElemsText is given the HTMLTableCell object coresponding to the r C values and from that puts the innerText for that cell in the array element Data(r, C)
    It does it in a somewhat indirect way. Briefly in words: In the “html node tree structure” we have many nodes , and we can “go down” to the . ChildNodes(0) . ChildNodes(1) , ChildNodes(2) …. for as many as there are at the “next level down”. Even for the case of our simple cells we have two levels. The first does not refer to the level where the text is. The routine detects that and will keep “going down” until a node level corresponding to a text is found. This does not have much relevance for our situation, other than each Call of the routine results in it being done twice: the routine “Calls itself” which actually means that the routine pauses whilst a second copy of the routine is made. For our simple data example, the text is actually got on the second copy run of the routine. !!
    This general process of the routine “calling itself” is the classic recursion process. This takes some careful and long explaining and is better demonstrated with a more complicated cell example using a reduced test data sample, see here for example: #####
    Because of how this routine works, it does not actually get text from the run of the routine taking in the HTMLTableCell object, because the node associated with that is not a text. It is the “next node down” that is recognised as a text node !!
    In addition, a further extra function of the routine is that when it does get at a text node, it first does an additional test to see if text was present as the current running copy of the routine. This would be the case of something like a paragraph: Since text will have been added before we finally come back up all the levels of the routine calling itself. The new text will then be concatenated with a "~" so that we could have the possibility to re split this text later. The second copy run of the routine at each Cell will take the same empty string with it which was supplied as the next array element to be filled in the previous ( fist copy) run of the routine

    For the purposes of our requirement , the extra abilities of the routine should never be needed, but you never know… it does no harm to have it there , just in case….

    _.___

    '4b(ii)c Output from Array
    I have left this section fairly simple for now as I may come back to it later, and adjust once I have used the routine a few times



    _.________________________________________________ ________________________

    Here is an initial File. I will likely customise it and the coding in it the next few days
    WMI Query.xlsm : https://app.box.com/s/z15s0syizlct1nufhivl2yu4iupek8pi

    Here again is the links to the initial coding:
    http://www.excelfox.com/forum/showth...0896#post10896
    http://www.excelfox.com/forum/showth...0897#post10897
    http://www.excelfox.com/forum/showth...0898#post10898


    Last edited by DocAElstein; 01-10-2019 at 01:28 AM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  9. #49
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10

    Positioning of procedure separation Line in a code module in the VBIDE

    Positioning of procedure separation Line in the Visual Basic Development Environment

    These are some notes based on a discussion here.. http://www.eileenslounge.com/viewtopic.php?f=30&t=31756
    Lisa Green had noticed something strange in how VBA divides procedures.....

    It appears that in VBA, that is to say in the Visual Basic Development Environment Window , ( that window seen by hitting Alt+F11 from a spreadsheet ) , the convention has been set to separate procedures by a line extending across the code pane Window.
    We see these as appearing as a series of underscores, __________________ , extending across the Visual Basic Development Environment Window
    Code:
    End Sub  '  The dividing line appears to us as a line of underscores ____ 
    


    Usually, if we did write exactly this ' The dividing line appears to us as a line of underscores ____ ' , on that terminating line above , then we would not see those underscores, ____ , as they get hidden in the terminating line:
    Hidden_____InDividingLine.JPG : https://imgur.com/7DyP9Om
    Attachment 2142Hidden_____InDividingLine.JPG
    The above screenshot shows the simplest case of routines with no "space" in between. In that simple case, the position of the dividing line is as expected in between the procedures. The situation is a bit more complicated if there is a separation in between procedures….

    Effect of blank lines ( or 'commented lines ) In Between
    Between procedures we may add blank lines or ' comment lines. If this is done, it appears that the convention has been set to place the line somewhere between the procedures in this blank/ 'comment range, and the lines above the line "belong" to the procedure above, that is to say the last or preeceding procedure, and the lines below the line "belong" to the procedure below, that is to say the next procedure, http://www.eileenslounge.com/viewtop...=31756#p245845

    The documentation is not 100% clear on how the position of the dividing is determined , that is to say how the row on which it physically appears as a long series of underscores, __________________ is determined
    There is no obvious logic to the way in which the dividing line can be positioned, that is to say , how to determine on which the dividing line appears as a long series of underscores, __________________

    Some initial experiments suggest that is influenced by positioning of blank lines and any single underscores _

    Line continuation / Break points : single underscores _
    We note in passing , that single underscores are used in coding generally to allow us to divide a single line of code into several lines for ease of reading. For example:
    Code:
    ' http://www.excelfox.com/forum/showthread.php/2293-Move-values-in-rows-at-the-end-of-the-preceding-row-*SOLVED*?p=10891#post10891
    Sub LineContunuationUnderscores() ' https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/how-to-break-and-combine-statements-in-code
      Dim LastRow As Long
      LastRow = Cells(Rows.Count, "A").End(xlUp).Row
      
    ' Without line breaks
      Range("A1:A" & LastRow) = Evaluate(Replace(Replace("IF(ISNUMBER(0+SUBSTITUTE(SUBSTITUTE(A2:A#,"" "",""""),"","","""")),IF(LEFT(A1:A@,4)=""2018"",TRIM(A1:A@&"" ""&A2:A#),""""),IF(LEFT(A1:A@,4)=""2018"",A1:A@,""""))", "#", LastRow + 1), "@", LastRow))
      
    ' With Line breaks
      LastRow = _
         Cells(Rows.Count, "A").End(xlUp).Row
      Range("A1:A" & LastRow) = Evaluate(Replace(Replace(  _
                                "IF(ISNUMBER(0+SUBSTITUTE(SUBSTITUTE(" &  _
                                "A2:A#,"" "",""""),"","","""")),IF(LEFT(A1:A@,4)" & _
                                "=""2018"",TRIM(A1:A@&"" ""&A2:A#),"""")," &  _
                                "IF(LEFT(A1:A@,4)=""2018"",A1:A@,""""))", "#", _
                                LastRow + 1), "@", LastRow))
    '  This is _
         acceptable in _
    or out of a  procedure
    End Sub
    '  This is _
         acceptable in _
    or out of a  procedure__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    Further, we note that the line continuation , sometimes called a line break, _ , also applies to comments whether in a procedure or between procedures:
    ' This is _
    acceptable in _
    or out of a procedure


    _._________

    Determining position of horizontal line dividing procedures when blank or comment lines are between procedures
    Sir Narios
    .

    The documentation is not 100% clear on how the position of the dividing is determined , that is to say how the row on which it physically appears as a long series of underscores, __________________ is determined
    There is no obvious logic to the way in which the dividing line can be positioned, that is to say , how to determine on which the dividing line appears as a long series of underscores, __________________
    Some initial experiments suggest that is influenced by positioning of blank lines and any single underscores _
    There appear to be 3 scenarios to consider in order to place the line somewhere in between, ( 4 if you consider the simple case of all lines containing comments or all lines being blank )

    Scenario 0
    ' _(0)
    If all lines are blank, or all lines are full with comments ( which exclude line continuations )
    No single underscores in any line
    The break is immediately after the Last/ upper procedure. (This is the same as the case for no separation between routines )
    Scenario 0 .JPG : https://imgur.com/pA4grFL
    Attachment 2143 Scenario 0 .JPG
    Code:
    Sub Scenario_0()
    ' _(0)
    End Sub___________________________________________________________________________________________________________________________________________________________________________________________________________
    
    
     Sub senario_0()
    ' _(0)
    End Sub_____________________________________________________________________________________________________________________________________________________________________________________________________________________
    '
    '
    '
    Sub surnario_0()
    ' _(0)
    End Sub_____________________________________________________________________________________________________________________________________________________________________________________________________________________________

    Scenario 1
    ' _(i) Attachment 2141 SirNario_1.JPG . https://imgur.com/zmr2up2 Scenario 1 .JPG
    If no line continuations are present and there is a one or more blank lines, then the line before the first blank line down from the upper routine is taken as the break point.
    No single underscores in any line
    Code:
    Sub Senario_1()
    ' _(i)
    End Sub
    '
    '________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    
    Sub surnaria_1()
    ' _(i)
    End Sub
    '____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    
    ''
    
    '
    Sub Sirnario_1()
    ' _(i)
    End Sub_______________________________________________________________________________________________________________________________________________________________________________________________________________
    
    
    '
    '
    Sub snaria_1()
    ' _(i)
    End Sub

    Scenario 2
    ' _(ii) Attachment 2144 SirNario_2.JPG : https://imgur.com/D2LqloV Scenario 2.JPG
    If there are one or more line continuations present then the break point will be placed at the first blank line down after the last line after the line continuation … unless scenario (iii)
    Code:
    Sub Scnari_2()
    ' _(ii)
    End Sub
    
    ''
    '
    ' _
    
    '____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    
    '
    
    Sub Sernario_2()
    ' _(ii)
    End Sub
    '
    '
    ' _
    '
    '___________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    
    '
    Sub Sirnarnio_2()
    ' _(ii)
    End Sub
    Scenario 3
    ' _ (iii) Attachment 2146 SirNario_3.JPG : https://imgur.com/ho56uBN Scenario 3.JPG
    There are no blank lines after the first line looking down after the last line continuation looking down, or after the first line looking down after the last line continuation looking down all lines contain comments . In this case, the break is at the line after the line on which the line continuation is on.

    Code:
    Sub scenario_3()
    ' _(iii)
    End Sub
    ''
    ' _
    ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    '
    '
    Sub SirNario_3()
    ' _(iii)
    End Sub
    
    '
    ' _
    '____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    '
    '
    Sub snuaro_3()
    ' _(iii)
    End Sub
    '
    
    '
    ' _
    ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    
    
    
    
    
    Sub SirNario_3()
    
    End Sub
    '
    ' _
    '____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
    
    
    
    Sub SurNario_3()
    
    End Sub

    In the next post is some attempt at a worded explanation of the situation.
    Last edited by DocAElstein; 02-25-2019 at 03:34 PM.

  10. #50
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Following on from the last post ... and ......... some notes based on a discussion here.. http://www.eileenslounge.com/viewtopic.php?f=30&t=31756 .....Lisa Green had noticed something strange in how VBA divides procedures.... some "VB stangeness" .

    _.............................



    Worded conclusion
    Attempting to put into words what is happening, or perhaps more of an attempt at words to fit the situation: ( Generally if I am referring to the sections between procedures, then this can also be taken as valid for the section between a last declaration at the top of a code module and the first procedure )
    Scenario 0
    The documentation tends to suggest that comments between procedures belong to the procedure below. This would suggest that the dividing line would be immediately below , for example , an End Sub. Indeed this situation is very typically seen. If all in between lines are comments then we see this. Given that the documentation states this, then it could be that something is in place to cause this positioning of the dividing line to behave in this way.
    If not all lines are comments, then the situation might not particularly have been thought out and might have been left to chance
    If all lines are blank then we see a similar situation: the dividing line would be immediately below , for example , an End Sub. This could be explained by no comments meaning the break point is simply left at immediately below , for example , an End Sub. There is no reason to think that the position as defined so far should be modified in this last situation
    That all sound reasonable.

    Now consider what might be a reasonable situation of wanting comments immediately below a routine and also wanting comments above a routine. This could be a reasonable requirement: Notes before or after things is a reasonable all day life situation to have.
    Further reasonable assumption is that for neatness these 2 sets of comments would be separated for clarity by one or more blank lines. This leads on to
    Scenario 1
    If we have initially all comment lines, and then make one or more lines blank, then the dividing line “moves down” to the line before the first blank line. We could reasonably interpret this to .. the unbroken comments immediately below the last End as belonging to that last above routine, and a blank line signalising their end.
    Code:
    Option Explicit
    '
    '____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
       Empty Line
    '
    '
    Sub   SubAbove()
    
    End Sub
    ' Comments under a sub
    ' last Comment under a sub____________________________________________________________________________________________________________________________________________________________________________________________________________________________________
      Empty Line
       Empty Line
    ' First Comment above a Sub
    ' Comment above a Sub 
    Sub SubBelow()
    
    End Sub
    ( Above I am using Empty Line to signalise blank lines - In reality those lines are blank: Scenario1 Explanation.JPG : https://imgur.com/Jzd2nJZ Scenario1 Explanation.JPG )

    Scenarios 2 an 3 general considerations ( Line breaks _ )
    We are considering line breaks _ . More specifically in comment lines, ' ____
    , since in between procedures or between a procedure
    Most things in computing are in, reality, just long strings of characters. If you examine the string that you are able to obtain from the entire contents of a code module ( http://www.excelfox.com/forum/showth...1016#post11016 ) then you find that
    _ the long dividing lines across a module don’t seem to be within that string, and
    _ the _ used as a line break appears as a normal character without any extra “hidden” characters other than the usually vbCr & vbLf associated with every line.
    It is therefore a good assumption that some post processing is responsible for defining the behaviour of the underscore within comments in between procedures

    Considering those two _ points above, I think we can further break an attempt to understand what is going on into one,
    rather vague guess,
    and a
    further more reasonable set of explanations

    Possibly there is some post processing in place which is designed to recognises a _ at the end of a module code line as linking a code line. Possibly its use in comments between procedures was not particularly considered. This could explain that a by product of this is that, which we observe, whereby a the dividing line never is placed above the line below a break point. In other words , you will never experience that in these two situations, _....
    Code:
    '
    '          _
    '____________________________________________________________________________________________________________________________________
    '
    
    Sub Human()
    ' Poo
    End Sub 
    
    
    '          _
    ______________________________________________________________________________________________________________
    '
    '
    
    _.. that the dividing line will be placed further up than I have indicated, ( There may be situations where they will be placed further down). An explanation of this could be that the post processing to determining the position of the dividing line may mistake that situation as a code line, and also therefore presume that it is an End type situation:
    Code:
    '
    ' _This_may_be_mistaken_as_a_code_line_with_a__
    '___________break_line_in_it,_and_consequently_this_module_line_may_be_mistaken_as_an_End_procedure_type_line___________________________________________________________________________
    '
    
    Sub Human()
    ' Poo
    End Sub 
    
    
    ' This_may_be_mistaken_as_a_code_line_with_a__
    _________break_line_in_it,_and_consequently_this_module_line_may_be_mistaken_as_an_End_procedure_type line____________________________________________________________
    '
    '
    
    If we assume that the above guess for the situation is correct, then scenario2 and scenario 3 , which are the scenarios when a _ is present between procedures, follow on directly from scenario0 and scenario1
    If we assume that the first comment line looking up from a procedure with a trailing _ is as described above, considered as like a _pseudo End Sub__________

    '
    ' _______
    _pseudo End Sub __________________________________________________ __________


    It then follows,
    Scenarion3 = Scenario0 and
    Scenarion2 = Scenario1

    Scenarion3 = Scenario0
    All comment lines or all blank lines below the pseudo End
    Code:
    '
    '         _ 
    _____pseudo End Sub____________________________________________________________________________________________________
    '
    '
    '
    Sub Sconari3()
    
    End Sub
    
    '
    '   _
    '_____pseudo End Sub____________________________________________________________________________________________________________
    '
    '
    '
    Sub Scenari3()
    
    End Sub
    
    '    _
    '____pseudo End Sub___________________________________________________________________________________
    
    
    Sub Scenaro3()
    
    End Sub
    
    '
    '       _
    ______pseudo End Sub________________________________________________________________________________________________
    
    
    Sub Sceanrio3()
    
    End Sub
    Scenarrio3.JPG : https://imgur.com/K8fSKrf : Scenarrio3.JPG
    So we have the situation that comes close to the simple documentation inferred idea: Comments belong to the procedure below


    Scenarion2 = Scenario1
    ( After the End ( real or pseudo ) not all lines are either all blank or all contain comments)
    The first possibility to separate by a blank line is taken looking down from the End :
    Code:
    '
    Option Explicit
    '
    '    _
           pseudo End of declaration section
    '____Last comment in Declaration section  ______________________________________________________________________________________________________________
    
    Sub Subsnario2()
    
    End Sub 
    '
    '
    ' Comments under a sub
    ' last Comment line _
    _______under a sub______pseudo End Sub  ______________________________________________________________________________________________________________ 
    
    ' First Comment above a Sub
    ' Comment above  a Sub
    '
    
    Sub Ssenario2()
    
    End Sub 
    
    '
    '   _
    _____pseudo End Sub ______________________________________________________________________________________________________________
    
    
    '
    Sub Sconari2()
    
    End  Sub  
    '
    '  _
    '        pseudo End Sub
    '
    '______________________________________________________________________________________________________________
    
    Sub Scenari2()
    
    End Sub
    
    '  _
    '_____pseudo End Sub______________________________________________________________________________________________________________
    
    '
    Sub Scenaro2()
    
    End Sub
    
    '
    '    _
    ______pseudo End Sub______________________________________________________________________________________________________________
    
    
    Sub Sceanrio2()
    
    End Sub
    Scnario 2 .JPG : https://imgur.com/WJF5JAb : Scnario 2 .JPG

    _.________________________

    The next post attempts the briefest summary possible:
    Last edited by DocAElstein; 02-27-2019 at 07:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •