使用VBA上传到Web

时间:2019-04-01 06:36:43

标签: excel vba web upload

<div id="xe-editor-container-1" class="input_area xpress_xeditor_editing_area_container" style="height: 400px;">
 <iframe id="editor_iframe_1" allowtransparency="true" frameborder="0" src="http://my_URL.or.kr/xe/modules/editor/styles/default/editor.html" scrolling="yes" style="width: 100%; height: 400px; display: block;">
      <html xmlns="http://www.w3.org/1999/xhtml>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <link rel="stylesheet" type="text/css" href="editor.css">
      <title>XpressEngine</title>
      </head>
      <body class="xe_content editable"></body>
      </html>			
 </iframe>
 <textarea id="xpress-editor-1" rows="8" cols="42" style="display: none; width: 100%;"></textarea>
 <textarea rows="8" cols="42" class="input_syntax " style="display:none"></textarea>
</div>

我想复制两个表,Sheet1上的ListObjects(“ Tbl1”),Sheet2上的ListObjects(“ Tbl2”),然后将它们作为单个帖子上传到网络上。

表的范围可以每次更改。

登录到网络,导航到公告板,按下写入按钮,然后成功键入标题。

但是我没有上传帖子。

也许找不到公告板对象。

我通过搜索网络创建的代码。

上面的HTML是电路板的HTML代码。

With ie
    .navigate "http://my_URL/offering"
    ieBusy ie   'Procedure fetched as search (check the ready status)

    .Document.getElementsByClassName("ico_16px write")(0).Click
    ieBusy ie

    Dim oTitle As Object, Ocontents As Object

    Set oTitle = .Document.getElementsByname("title")(0)   'Sometimes fail(sometimes Nothing)
    Set oContents = .Document.getElementsByClassName("xe_content editable")(0) 'evry time fail(=Nothing)

    oTitle.Value = "my Title"
    oContents.Value = ????
    .Document.forms(0).submit   'I could not confirm it because it did not work anymore.

End With
Sub ieBusy(ie As Object)
    Do While ie.Busy Or ie.readyState < 4
        DoEvents
    Loop
End Sub

标题HTML

enter image description here

板载HTML

enter image description here

1 个答案:

答案 0 :(得分:0)

1)使用附加的定时循环,按照https://stackoverflow.com/a/55334183/6241235设置oTitle

2)我认为您的oContents变量正在选择位于iframe中的元素。我希望您改而将textarea元素作为目标。 iframe之后有两个。第一个具有ID xpress-editor-1