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
Worksheet: Equipment PM
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
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:
Information that looks like it might be relevant isHTML 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>
_ 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




Reply With Quote
Bookmarks