2016-11-07 56 views
-1

我試圖使用VBScript自動化SharePoint表單,因爲我沒有權限在計算機上安裝任何軟件。如何使用VBScript僅使用類名識別隱藏字段

目前有一個字段,默認情況下是一個textarea。它不會是可見的,並點擊它的類名變化:(預期類沒有其他領域來識別它

我試着使用類名訪問它,但VBScript找不到它, classname有一些空白,所以我elemenating它。下面是代碼。

For Each elem In IE.Document.getElementsByTagName("div") 
    Dim r, s 
    Set r = New RegExp 
    r.Global = True 
    r.Pattern = "^\s+|\s+$" 
    id = r.Replace(id, "") 
    s = r.Replace(elem.getAttribute("class"), "") 

    If s = id Then 
     WScript.Echo "found class" 
     WScript.Sleep 1000 
     WshShell.SendKeys "found" 
     s.value = "found" 
     elem.value = "found" 
     Exit For 
    End If 
Next 

我甚至嘗試下面的代碼,但不能被執行的操作,顯示回波信息,但點擊或直接進入操作不執行數據。

AllObjects = IE.Document.all.length 
for i=0 to AllObjects 
    If Trim(IE.Document.all(i).getAttribute("class")) = "nicEdit-main" Then 
     IE.Document.all(i).Click 
     IE.Document.all(i) = "found" 
     WScript.Echo i, IE.Document.all(i).getAttribute("class") 
     Exit For 
    End If 
Next 
+0

一些人給這問題的負面點,爲什麼?很多人都問過這個問題,我找到了答案。 – Vincent

回答

0

這個嘛是混亂的,我已經試過這沒有奏效過,但現在它的工作,只是使用focus方法和它的作品

WsShell.SendKeys "text" 

享受:d