Created
September 10, 2019 14:07
-
-
Save hamaguchi-amago/2728d090a52cc5bdab65384ef31cb6da to your computer and use it in GitHub Desktop.
HTML変換処理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute VB_Name = "Module1" | |
Sub ファイル出力() | |
Attribute ファイル出力.VB_Description = "定義書用のマクロを出力する" | |
Attribute ファイル出力.VB_ProcData.VB_Invoke_Func = "O\n14" | |
' | |
' ファイル出力 Macro | |
' 定義書用のマクロを出力する | |
' | |
' Keyboard Shortcut: Ctrl+Shift+O | |
' | |
Dim ws As Worksheet | |
Set ws = ActiveSheet | |
Dim trs As String | |
Dim tds As String | |
Dim i As Long | |
i = 1 | |
Do While ws.Cells(i, 1).value <> "" | |
Dim workTr As String | |
If i = 1 Then | |
workTr = "<tr style=""background-color: rgb(153 , 255 , 255)"">" | |
Else | |
workTr = "<tr>" | |
End If | |
tds = "" | |
Dim j As Long | |
For j = 1 To 15 | |
Dim value As String | |
If ws.Cells(i, j).value = "" Then | |
value = "" | |
Else | |
value = ws.Cells(i, j).value | |
End If | |
tds = tds & "<td>" & value & "</td>" | |
Next j | |
trs = trs & workTr & tds & "</tr>" | |
i = i + 1 | |
Loop | |
Dim datFile As String | |
datFile = ActiveWorkbook.Path & "\" & ws.Name & ".txt" | |
Open datFile For Output As #1 | |
Print #1, "<table border=""1"" width=""100%"" style=""width: 100% ; height: 100% ; border-collapse: collapse""><tbody>" & trs & "</tbody></table>" | |
Close #1 | |
MsgBox ws.Name & ".txt" & "に書き出しました" | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブログの記事で作成しました。
興味のある方はご覧ください。
Excelの表をhtmlに変換するツールをVBAで作ってみた
https://neko-py.com/excel-table-html