我正在尝试使用MSHTML对象在vba中创建一个按钮,然后将其添加到Outlook mailitem,然后使用wordpress api将mailitem发布到网站。我可以完成大部分工作,但是我无法弄清楚如何使用对象来构建按钮元素,而不是简单地从字符串中构建按钮元素,这是一个令人困惑的大麻烦。
这是我要创建的表单:
<form>
<input style="width: 300px; padding: 20px; cursor: pointer; box-shadow: 6px 6px 5px; #999; -webkit-box-shadow: 6px 6px 5px #999; -moz-box-shadow: 6px 6px 5px #999; font-weight: bold; background: #ffff00; color: #000; border-radius: 10px; border: 1px solid #999; font-size: 150%;" type="button" value="Put Your Text Here" onclick="window.location.href='http://www.hyperlinkcode.com/button-links.php'" />
</form>
这就是我要尝试的方式:
Dim httpContent As MSHTML.HTMLDocument
Dim httpForm As MSHTML.HTMLFormElement
Set httpContent = New MSHTML.HTMLDocument
Set httpForm = httpContent.createElement("form")
httpForm.Action = "http://www.hyperlinkcode.com/button-links.php"
httpForm.value = "Put Your Text Here"
httpForm.name = "call to action"
With httpForm 'the following is almost right
.setAttribute "width", 500
.setAttribute "padding", 20
.setAttribute "box-shadow", 6
.setAttribute "-webkit-box-shadow", 6
.setAttribute "-moz-box-shadow", 20
.setAttribute "font-weight", "bold"
.setAttribute "background", "#ffff00"
.setAttribute "border-radius", 10
.setAttribute "border", 1
.setAttribute "font-size", 150
End With
httpButton.onclick = "window.location.href='http://www.hyperlinkcode.com/button-links.php'"
httpContent.appendChild httpButton
上面的大多数命令都可以执行,但是在单击按钮和访问网站之间似乎没有任何联系。