Creating HTM file via Excel VBA

This post VBA code never been used in final application by me – but in test files it was used. I’ve spent a little bit time on it. Code is quite interesting becasue of HTML tags used inside to create HTM file that is being opening in internet browser.

Creating HTM file guarantees as the same schema (should be) for all workstations. Plik HTM has been created be me when PDF SAVE AS tool has not been a part of Excel.

Following sources have been used to create HTM file:
1. Create HTM files from sheet data
2. Extension filters for saving files
3. Different table styles in CSS
4. Font size in CSS
5. Polish signs in Firefox

For tests some data have to be added to active sheet – the best as in following image:

How to create HTM file:

' Source:
' Create HTM files from sheet data
' http://www.meadinkent.co.uk/xlhtmltable.htm
' Extension filters for saving files
' http://software-solutions-online.com/2014/03/13/excel-vba-save-file-dialog-getsaveasfilename/
' Different table styles in CSS
' http://stackoverflow.com/questions/7992198/html-how-to-make-2-tables-with-different-css
' Font size in CSS
' http://www.w3schools.com/tags/att_font_size.asp
' Polish signs in Firefox
' http://forums.phpfreaks.com/topic/132413-polish-characters-dont-display-properly/

Sub HTM_Page_Creation()

Dim TempStr
Dim PageName As String
Dim MyFormats As Variant
Dim FirstRow, LastRow, FirstCol, LastCol, MyRow, MyCol As Integer

' ----------------------------------
' HTM FILE LOCALIZATION

PageName = Application.GetSaveAsFilename("HTM_File_Name", "HTM file (*.htm), *.htm", 1, "Save raport")
' Checking if user chosen CANCEL action
If PageName = "False" Then
    MsgBox "CANCELED.", vbOKOnly + vbInformation, "CONFIRMATION..."
    Exit Sub
End If

' ----------------------------------
' VARIABLE DECLARATION

' MyFormats is an array which can contain formats for numbersand dates. Add one element for each table column.
MyFormats = Array("#", "dd mmm yy", "# ##0 pln", "0%")

' HTM table range
FirstRow = 1
LastRow = 6
FirstCol = 1
LastCol = 4

' ----------------------------------
' CHECKING DATA CORRECTION (admit I don't know how it works)

'If error macro is stopped
'If UBound(MyFormats2) < (LastCol - FirstCol) Then
'    MsgBox "No data - code has been stopped", vbOKOnly + vbCritical, "HTM Creation..."
'    Exit Sub
'End If

' ----------------------------------
' HTM FILE CREATION

Open PageName For Output As #1
Print #1, "<html>"
Print #1, "<head>"
Print #1, "<title>COMPANY SALE RAPORT</title>" ' is showing in browser tab
Print #1, "<meta http-equiv='content-type' content='text/html;charset=windows-1250' />" ' polish signs in Forefox
Print #1, "<style type='text/css'>"
Print #1, "body {font-family: Arial, Helvetica; font-size: 11pt; margin-left: 10; margin-right: 10}"
Print #1, "td.td1 {padding: 1pt 3pt 2pt 3pt; border-style: solid; border-width: 1; border-color: #0F5BB9; font-size: 11pt}"
Print #1, "table.table1 {border-collapse: collapse; border-width: 1 ; border-style: solid; border-color: #0F5BB9 }"
Print #1, "p.p1 {font-size: 8pt}"
Print #1, "</style>"
Print #1, "</head>"

Print #1, "<body>"
Print #1, "<h1>PAGE TITLE</h1>"
Print #1, "<p></p>"
Print #1, "<table class='table1'>"
Print #1, "<p></p>"

' Adding data to HTM files
For MyRow = FirstRow To LastRow
    Print #1, "<tr>"
    For MyCol = FirstCol To LastCol
            If MyRow = 1 Then
                TempStr = Cells(MyRow, MyCol).Value
                TempStr = "<b>" & TempStr & "</b>"
                TempStr = "<td class='td1'; align='center'; bgcolor='#58FAF4'>" & TempStr & "</td>"
            Else
                If IsNumeric(Cells(MyRow, MyCol).Value) = True Then
                    TempStr = Format(Cells(MyRow, MyCol).Value, MyFormats(MyCol - FirstCol))
                    TempStr = "<td class='td1'; align='right'>" & TempStr & "</td>"
                Else
                    TempStr = Cells(MyRow, MyCol).Value
                    TempStr = "<td class='td1'; align='left'>" & TempStr & "</td>"
                End If
            End If
        Print #1, TempStr
    Next MyCol
    Print #1, "</tr>"
Next MyRow

Print #1, "</table>"

' HTM file finalization
Print #1, "<p></p>"
Print #1, "<p class='p1'>To search some value use [CTRL]+'F'. Press[Home] to"
Print #1, "back on top. Data might be copied to Excel</p>"
Print #1, "<hr>"

Print #1, "<p><small>Raport date: " & Format(Date, "dd-mm-yyyy") & " | <a href='http://www.meadinkent.co.uk/'>File has been created thanks to  meadinkent</a></small></p>"
Print #1, "<p></p>"
Print #1, "<p><img src='Some image path'></p>"
Print #1, "</body>"
Print #1, "</html>"
Close #1

MsgBox "Done"

End Sub

357 thoughts on “Creating HTM file via Excel VBA

  1. Pingback: tangerine business account online

  2. Pingback: nằm mơ thấy con chí

  3. Pingback: mo thay cho chet

  4. Pingback: ป๊อกเด้งออนไลน์

  5. Pingback: nằm mơ thấy thỏ

  6. Pingback: mơ thấy xe máy đánh con gì

  7. Pingback: gamescheat

  8. Pingback: cây phong thuỷ phòng làm việc

  9. Pingback: cung song tử hợp với cung nào nhất

  10. Pingback: con gái thiên bình

  11. Pingback: mơ thấy mất xe đạp

  12. Pingback: mơ thấy quay lại với người yêu cũ

  13. Pingback: mơ thấy đứt tay

  14. Pingback: danh bai doi thuong tren pc

  15. Pingback: game dua ngua dat cuoc

  16. Pingback: ดูหนังออนไลน์เต็มเรื่อง

  17. Pingback: Bilåtervinnare Göteborg

  18. Pingback: mơ thấy quả bưởi đánh con gì

  19. Pingback: mơ thấy đồ ăn

  20. Pingback: chiem bao thay di chua

  21. Pingback: mơ ăn chuối

  22. Pingback: mơ bốc mộ

  23. Pingback: nằm mơ thấy tóc rụng

  24. Pingback: mơ chụp ảnh

  25. Pingback: http://instone-international.com/

  26. Pingback: Sicherheitsdienst

  27. Pingback: Tyson vs Jones jr live stream

  28. Pingback: cvv dumps with pin

  29. Pingback: www.squeeqee.co.uk/carpet-cleaning-enfield

  30. Pingback: pasarqq

  31. Pingback: buy real drivers license uk

  32. Pingback: Market Retailers

  33. Pingback: ตู้แปลภาษา

  34. Pingback: ดูการ์ตูนออนไลน์ อนิเมชั่น

  35. Pingback: mơ đánh chết người

  36. Pingback: mơ thấy cá lóc

  37. Pingback: mơ bị sét đánh

  38. Pingback: bị bọ cạp cắn

  39. Pingback: Boka hämtning skrotbil

  40. Pingback: mơ thấy nhà mới đánh con gì

  41. Pingback: mo thay toc

  42. Pingback: read this post here

  43. Pingback: 토토사이트

  44. Pingback: rescator su

  45. Pingback: evdamhft

  46. Pingback: what makes viagra work

  47. Pingback: wat is viagra voor mannen

  48. Pingback: how long does it take azithromycin to enter you system

  49. Pingback: cialis and viagra

  50. Pingback: viagra

  51. Pingback: comprar viagra

  52. Pingback: quick essay writing service

  53. Pingback: write my research paper reddit

  54. Pingback: writing my essay

  55. Pingback: help me in essay writing

  56. Pingback: business essay writing

  57. Pingback: augmentin generic brand

  58. Pingback: where can i get furosemide

  59. Pingback: azithromycin brand name in india

  60. Pingback: ivermectin stromectol

  61. Pingback: ventolin australia

  62. Pingback: acne pills doxycycline

  63. Pingback: prednisolone 5mg price

  64. Pingback: reviews on clomid

  65. Pingback: dapoxetine 30mg reviews

  66. Pingback: diflucan toenail fungus

  67. Pingback: synthroid weight

  68. Pingback: propecia shedding pictures

  69. Pingback: neurontin impotence

  70. Pingback: metformin hydrochloride

  71. Pingback: paxil and oxycodone

  72. Pingback: sanofi aventis plaquenil

  73. Pingback: metformin 500 mg otc

  74. Pingback: propecia

  75. Pingback: where to buy finasteride

  76. Pingback: ordering cialis online australia

  77. Pingback: medication for ed dysfunction

  78. Pingback: medication canadian pharmacy

  79. Pingback: buy cialis cheaper online

  80. Pingback: Zakhar Berkut hd

  81. Pingback: 4569987

  82. Pingback: buy cialis in miami

  83. Pingback: cialis 20mg usa

  84. Pingback: how to buy cialis online uk

  85. Pingback: buy insurance

  86. Pingback: news news news

  87. Pingback: ordering online australia

  88. Pingback: psy

  89. Pingback: psy2022

  90. Pingback: projectio-freid

  91. Pingback: best payday loans turlock

  92. Pingback: Tinder Says I Have A Message But I Can't See It

  93. Pingback: kinoteatrzarya.ru

  94. Pingback: topvideos

  95. Pingback: video

  96. Pingback: viagra with alcohol

  97. Pingback: lisinopril 20mg online

  98. Pingback: afisha-kinoteatrov.ru

  99. Pingback: Ukrainskie-serialy

  100. Pingback: site

  101. Pingback: generic cialis pricing

  102. Pingback: cialis v viagra

  103. Pingback: top

  104. Pingback: cialist the yeloow pill

  105. Pingback: canada cialis online

  106. Pingback: canadian online pharmacy calls

  107. Pingback: cost of cialis without insurance

  108. Pingback: viagra vs cialis vs levitra price

  109. Pingback: best rx online pharmacy

  110. Pingback: buy cialis without perscription

  111. Pingback: cialis online without prescription

  112. Pingback: cialis without presciption in usa

  113. Pingback: declaring prescription drugs us customs

  114. Pingback: buy cialis online viagra

  115. Pingback: where can i buy cialis without a prescription

  116. Pingback: ed medicines

  117. Pingback: valtrex 250 mg 500 mg

  118. Pingback: erectile dysfunction medicines

  119. Pingback: cause of ed

  120. Pingback: viagra without a doctor prescription usa

  121. Pingback: cialis brand name

  122. Pingback: sildenafil viagra 100mg

  123. Pingback: soderzhanki-3-sezon-2021.online

  124. Pingback: chelovek-iz-90-h

  125. Pingback: podolsk-region.ru

  126. Pingback: voltaren cream for arthritis

  127. Pingback: male ed drugs

  128. Pingback: bender na4alo 2021

  129. Pingback: blogery_i_dorogi

  130. Pingback: blogery_i_dorogi 2 blogery_i_dorogi

  131. Pingback: erectile dysfunction pills

  132. Pingback: generic ivermectin cream

  133. Pingback: stromectol 12mg

  134. Pingback: plaquenil sulfate

  135. Pingback: ivermectin 5 mg price

  136. Pingback: ivermectin 80 mg

  137. Pingback: best ed solution

  138. Pingback: best ed pills at gnc

  139. Pingback: chernaya vodova

  140. Pingback: 66181

  141. Pingback: erectile dysfunction medicines

  142. Pingback: buy hydroxychloroquine sulphate

  143. Pingback: Porno

  144. Pingback: vechernyy urgant

  145. Pingback: ukraine

  146. Pingback: viagra from india

  147. Pingback: best place to buy viagra online

  148. Pingback: A3ixW7AS

  149. Pingback: how to buy cialis online uk

  150. Pingback: hydroxychloroquine stock

  151. Pingback: buy plaquenil tablets

  152. Pingback: gidonline-ok-google

  153. Pingback: link

  154. Pingback: KremlinTeam

  155. Pingback: medunitsa.ru

  156. Pingback: plaquenil cost for generic

  157. Pingback: kremlin-team.ru

  158. Pingback: psychophysics.ru

  159. Pingback: yesmail.ru

  160. Pingback: cialis bayer 20

  161. Pingback: hydroxychloroquine tablets buy online

  162. Pingback: lowest price cialis

  163. Pingback: Suicide Squad 2

  164. Pingback: psiholog

  165. Pingback: order viagra sydney australia

  166. Pingback: hizhnyak-07-08-2021

  167. 가장 인기가 많은 토토사이트를 선별하여 방문자들에게 제공하는 붐토토는 검증 된 안전놀이터,메이저사이트만을 고집합니다. 꽁머니 이벤트 등 사설스포츠토토를 이용.토토

  168. Pingback: cialis after prostate surgery

  169. Pingback: rate canadian pharmacy online

  170. Pingback: zithromax for sale usa

  171. Pingback: viagra without a prescription

  172. Pingback: zithromax buy online

  173. Pingback: what does viagra do

  174. Pingback: where can you buy zithromax

  175. Pingback: u.s online pharmacy

  176. Pingback: https://regcialist.com

  177. Pingback: pharmacy symbol rx

  178. Pingback: generic ivermectil at kroger

  179. Pingback: viagra side effects

  180. Pingback: stromectol uk buy

  181. Pingback: medication drugs

  182. Pingback: can you buy stromectol online uk

  183. Pingback: plaquenil cost without insurance

  184. Pingback: best price cialis supper active

  185. Pingback: cialis side effects women

  186. Pingback: priligy 60

  187. Pingback: prednisone capsules

  188. Pingback: amlodipine for cats

  189. Pingback: what is atorvastatin calcium 40 mg used for

  190. Pingback: jack prilosec

  191. Pingback: pills from canada

  192. Pingback: what are the side effects of lexapro

  193. Pingback: legitimate canadian pharmaceuticals online

  194. Pingback: buy viagra online cheapest

  195. Pingback: what is duloxetine hcl dr 60 mg capsule

  196. Pingback: generic ivermectin for humans

  197. Pingback: dosage for hydrochlorothiazide

  198. Pingback: will stromectol treat std

  199. Pingback: generic viagra india

  200. Pingback: atorvastatin cholesterol

  201. Pingback: female viagra

  202. Pingback: viagra alternatives

  203. Pingback: klonopin and zoloft

  204. Pingback: mens erection pills

  205. Pingback: ivermectay clavulanic

  206. Pingback: how to get cialis

  207. Pingback: compare ed drugs

  208. Pingback: how to order cialis

  209. Pingback: citalopram vs lexapro

  210. Pingback: stromectol 6 treat parasite infestations 125

  211. Pingback: cheapest price for cialis

  212. Pingback: where can i purchase cialis

  213. Pingback: Duna 2021

  214. Pingback: viagra sale

  215. Pingback: sildenafil coupon

  216. Pingback: what is the purpose of duloxetine

  217. Pingback: viagra prescription online

  218. Pingback: 1

  219. Pingback: purchase cialis online

  220. Pingback: cheapest generic viagra

  221. Pingback: where to buy real viagra cheap

  222. Pingback: lowkey gay dating sites

  223. Pingback: clavamox 125

  224. Pingback: canadian pharmacy ezzz cialis

  225. Pingback: sildenafil online

  226. Pingback: clomid uk

  227. Pingback: buying clomid online

  228. Pingback: viagra 100mg

  229. Pingback: buy cialis now

  230. Pingback: buy ivermectin cream

  231. Pingback: prednisone 20 mg purchase

  232. Pingback: viagra alternative

  233. Pingback: how much is cialis in mexico

  234. Pingback: over the counter stromectol for lymphatic filariasis

  235. Pingback: how can i get viagra

  236. Pingback: buy doxycycline without prescription

  237. Pingback: ivermectin generic human

  238. Pingback: order viagra for women

  239. Pingback: cialis with dapoxetine paypal

  240. Pingback: where to buy v

  241. Pingback: ivermectin 6 mg

  242. Pingback: cialis 20mg overnight

  243. Pingback: cialis online canada paypal

  244. Pingback: ivermectin pills for dogs

  245. Pingback: ivermectin meta-analysis

  246. Pingback: generic cialis india

  247. Pingback: ivermectin oral

  248. Pingback: ivermectin for tapeworms

  249. Pingback: buying sildenafil citrate online

  250. Pingback: natural viagra alternatives

  251. Pingback: drugs market viagra

  252. Pingback: dosing of viagra for female sexual dysfunction

  253. Pingback: cheapest price soft generic viagra

  254. Pingback: ivermectin poisoning

  255. Pingback: ivermectin guinea pigs

  256. Pingback: ivermectin covid studies

  257. Pingback: comprare viagra online

  258. Pingback: cialis price costco

  259. Pingback: best ed pill

  260. Pingback: cialis seling

  261. Pingback: how to buy viagra for less than 5 dollars each

  262. Pingback: sexual dysfunction in men

  263. Pingback: impotence treatment

  264. Pingback: sildenafil mylan

  265. Pingback: where to buy cialis

  266. Pingback: cheap pharmacy online

  267. Pingback: sildenafil

  268. Pingback: payday loans lenders only

  269. Pingback: all casino slots games

  270. Pingback: viagra online canadian pharmacy

  271. Pingback: dapoxetine eu

  272. Pingback: how to get nolvadex

  273. Pingback: generic tamoxifen

  274. Pingback: prednisone 60 mg tablet

  275. Pingback: 10 mg prednisone tablets

  276. Pingback: ivermectin lotion price

  277. Pingback: ivermectin 8 mg

  278. Pingback: ivermectin lotion cost

  279. Pingback: buy z pack over the counter

  280. Pingback: prescription drugs online without

  281. Pingback: buy prescription drugs from canada cheap

  282. Pingback: online generic viagra

  283. Pingback: non prescription ed pills

  284. Pingback: bestellen viagra

  285. Pingback: cleantalkorg2.ru

  286. Pingback: viagra prescriptions over internet

  287. Pingback: prednisone 1 tablet

  288. Pingback: order prednisone 100g online without prescription

  289. Pingback: without doctor visit viagra

  290. Pingback: viagra foods

  291. Pingback: viagra dosages

  292. Pingback: viagra government funded

  293. Pingback: order stromectol

  294. Pingback: stromectol 0.5 mg

  295. Pingback: order prescription viagra online

  296. Pingback: amoxil USA

  297. Pingback: free viagra

  298. Pingback: lasix tablet cost

  299. Pingback: neurontin medicine

  300. Pingback: plaquenil brand

  301. Pingback: natural alternatives to viagra

  302. Pingback: prednisone 50 tablet

  303. Pingback: dapoxetine tablet

  304. Pingback: provigil generic buy

  305. Pingback: ivermectin generic

  306. Pingback: 270 mcg albuterol

  307. Pingback: buy zithromax online

  308. Pingback: viagra kopen

  309. Pingback: furosemide buy online

  310. Pingback: viagra cost

  311. Pingback: quineprox 0.4

  312. Pingback: natural viagra

  313. Pingback: ivermectin ireland

  314. Pingback: zithromax tablet

  315. Pingback: cheapest on line valtrex without a prescription

  316. Pingback: herb viagra

  317. Pingback: cheapest on line valtrex without a prescription

  318. Pingback: valtrex generic otc

  319. Pingback: levitra

  320. Pingback: viagra pornhub

  321. Pingback: over the counter viagra

  322. Pingback: generic pills

  323. Pingback: generic pills

  324. Pingback: cialis dosage frequency

  325. Pingback: cialis side effects dangers

  326. Pingback: cialis dosage recommendations frequency

  327. Pingback: viagra generic

  328. Pingback: buy hydroxychloroquine sulfate

  329. Pingback: cialis viagra

  330. Pingback: plaquenil 200mg buy

  331. Pingback: pfizer viagra price

  332. Pingback: pfizer viagra

  333. Pingback: ivermectin 8000

  334. Pingback: plaquenil 0.2

  335. Pingback: ivermectin 12mg tablets online

  336. Pingback: ivermectin gel

  337. Pingback: price of ivermectin

  338. Pingback: stromectol tab price

  339. Pingback: canadian pharmacy online cialis

  340. Pingback: generic cialis online pharmacy

  341. Pingback: aabbx.store

  342. Pingback: buying ed pills online

  343. Pingback: ne-smotrite-naverx

  344. Pingback: arrogant

  345. Pingback: sildenafil teva

  346. Pingback: Dead-Inside

  347. Pingback: cialis mg

  348. Pingback: how much does cialis cost at walmart

  349. Pingback: medicine for impotence

  350. Pingback: doxazosin and cialis

  351. Pingback: stromectol tablet 3 mg

  352. Pingback: ivermectin buy online

  353. Pingback: stromectol 12mg

  354. Pingback: trusted online pharmacy reviews

  355. Pingback: cialis commercials

Leave a Reply

Your email address will not be published. Required fields are marked *