掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Excelデータをhtmlで出力する際に改行するには? (ID:143451)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Excelデータをhtmlで出力する際に、D列のセルの文字列を改行してhtmlデータに表示させる方法を教えて下さい? 以下にコードを記載します。よろしくお願いします。 'メインのループ Sub test001_main() Dim y As Integer 'ループのカウンター y = 4 '4行目から While Cells(y, "A") <> "" 'A列に何か入っている間ループ 'ファイル作成のサブ関数に名前とファイル名を渡す Call test001_CreateHtmlFile(Cells(y, "B"), Cells(y, "C"), Cells(y, "D"), Cells(y, "E"), Cells(y, "F"), Cells(y, "G"), Cells(y, "H"), Cells(y, "I"), Cells(y, "J"), Cells(y, "K"), Cells(y, "L"), Cells(y, "M"), Cells(y, "N"), Cells(y, "O"), Cells(y, "P"), Cells(y, "Q"), Cells(y, "R"), Cells(y, "S"), Cells(y, "T"), Cells(y, "U")) y = y + 1 Wend MsgBox "作成が終了しましたデータを確認してください" End Sub '名前とファイル名を受け取り、HTMLファイルを作成するサブ関数 Sub test001_CreateHtmlFile(strMei As String, strHTML As String, strCt As String, strDt As String, strEt As String, strFt As String, strGt As String, strHt As String, strIt As String, strJt As String, strKt As String, strLt As String, strMt As String, strNt As String, strOt As String, strPt As String, strQt As String, strRt As String, strSt As String, strTt As String) Dim strFNAME As String 'ファイル名格納用 'ブックと同じ位置にxxx.htmlを作成する strFNAME = ThisWorkbook.Path & "\" & "INC-HR-" & strMei & ".html" 'ファイル名の作成 Open strFNAME For Output As #1 'ファイル番号1で新規作成 'データ書き込み、名前だけ変えて作成する Print #1, "<html>" Print #1, "<head>" Print #1, "<title>" & strMei & "</title>" Print #1, "</head>" Print #1, "<body>" Print #1, "<h1>" & "INC-HR-" & strMei & "</h1>" Print #1, "Range("; B1; ")" & strMei & "<br>" Print #1, "Range("; C1; ")" & strHTML & "<br>" Print #1, "Range("; D1; ")" & Replace(strCt, vbCrLf, "<br>") & "<br>" Print #1, "" Print #1, "" Print #1, "</body>" Print #1, "</html>" Close #1 '開いたら閉じようね End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.