Удалить разрыв строки, созданный тегом упорядоченного списка html - PullRequest
1 голос
/ 25 марта 2020

У меня возникают проблемы при попытке удалить разрыв строки, созданный при использовании упорядоченного списка в автоматической электронной почте Outlook (<ol>).

Что я пробовал:

  1. для реализации этого решения, но я не уверен, что это можно реализовать / прочитать через VBA
  2. для замены разрывов строк пробелами безрезультатно
  3. для объединения строки заголовка с тегом ol в той же строке (& "I want to remove the text between this line and my 1st ordered list <ol>" _)

Есть ли способ выполнить sh это с помощью VBA?

Код, вывод и желаемый вывод ниже:

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .SentOnBehalfOfName = "me@me.com"
        .to = Target.Offset(, 2)
        .cc = Target.Offset(, 3)
        .Subject = "Subject"
        .HTMLBody = "Hello StackOverflow " _
                    & "<br><br>" _
                    & "I want to remove the text between this line and my 1st ordered list" _
                    & "<ol>" _
                    & "<li> Text </li>" _
                    & "<ul>" _
                    & "<li> Bullet </li>" _
                    & "</ul>" _
                    & "<li> More Text </li>" _
                    & "</ol>"

Что я получаю:

enter image description here


Что я хочу:

enter image description here


I want to remove the text beween this line and my 1st ordered list
    'I WANT TO REMOVE THE BLANK SPACE HERE
    1.  Text

Ответы [ 2 ]

1 голос
/ 26 марта 2020

Вот решение: JSFiddle

<html>
	<head>
		<style>
		<!--
		/* Style Definitions */
		p.MsoNormal
			{margin:0in;
				margin-bottom:.0001pt;
				}
			
			
		p.MsoListParagraph
			{mso-style-priority:34;
				margin-top:0in;
				margin-right:0in;
				margin-bottom:0in;
				margin-left:.5in;
				margin-bottom:.0001pt;
				}
		-->
		</style>
	</head>

	<body>
	<div class=WordSection1>
		<p>Hello StackOverflow</p>
		<p class=MsoNormal>I want to remove the text between this line and my 1<sup>st</sup> ordered list</p>
		<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l1 level1 lfo1'>1.&nbsp;&nbsp;&nbsp;Text</p>
		<p class=MsoListParagraph style='margin-left:74.25pt;text-indent:-.25in;mso-list:l0 level1 lfo2'><span style='font-family:Symbol'>&middot;</span>&nbsp;&nbsp;&nbsp;Bullet</p>
		<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l1 level1 lfo1'>2.&nbsp;&nbsp;&nbsp;More Text</p>
	</div>
	</body>
</html>

VBA Пример

Option Explicit
Public Sub Example()
    Dim OutApp As Object
    Set OutApp = CreateObject("Outlook.Application")

    Dim OutMail As Object
    Set OutMail = OutApp.CreateItem(0)

    With OutMail
        .Subject = "Subject"

         ' Body Style
        .HTMLBody = "<html><head><style>" & _
            "<!-- p.MsoNormal" & _
                    "{margin:0in;margin-bottom:.0001pt}" & _
                 "p.MsoListParagraph" & _
                     "{mso-style-priority:34;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt}" & _
              "--> </style></head>" & _
            "<body>" & _
                "<div class=WordSection1>" & _
                    "<p>Hello StackOverflow</p>" & _
                    "<p class=MsoNormal>I want to remove the text between this line and my 1<sup>st</sup> ordered list</p>" & _
                    "<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l1 level1 lfo1'>1.&nbsp;&nbsp;&nbsp;Text</p>" & _
                    "<p class=MsoListParagraph style='margin-left:74.25pt;text-indent:-.25in;mso-list:l0 level1 lfo2'>" & _
                                        "<span style='font-family:Symbol'>&middot;</span>&nbsp;&nbsp;&nbsp;Bullet</p>" & _
                    "<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l1 level1 lfo1'>2.&nbsp;&nbsp;&nbsp;More Text</p>" & _
                "</div>" & _
            "</body>" & _
        "</html>"

        .Display
    End With

End Sub
0 голосов
/ 25 марта 2020

Предполагая, что вы можете использовать CSS, вы можете использовать margin-top для удаления пробела.

Заменить <ol> на <ol style="margin-top: 0;">

Только что заметил, что вы хотите сделать это с VBA, но не уверен, что вы подразумеваете под этим. Вы можете добавить изменение в свой VBA, но это просто рендеринг HTML, так что VBA действительно не входит в него?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...