我們的部門正在從SharePoint 2007切換到2010年。舊SharePoint允許我們爲表單使用相同的URL和Window標題,但SharePoint 2010顯示列表的URL和Window標題已填寫的表格。在該頁面中,有一個名爲「添加新項目」鏈接:vbscript訪問Sharepoint 2010表單以輸入收集到的數據
要進入一個新的形式,他們必須單擊鏈接;這與它自己的標題會彈出一個新窗口:
這裏是我去的第一個圖像的代碼:
URL = "http://myURL.com/AllItems.aspx"
Window = " - All Tasks"
URLFound = False
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
For Each objIE In objShell.Windows
Next
For i = 0 to objShellWindows.Count - 1
Set objIE = objShellWindows.Item(i)
On Error Resume Next
If InStr(UCase(objShellWindows.Item(i).LocationURL), UCase(URL)) Then
If InStr(UCase(objShellWindwos.Item(i).FullName), "IEXPLORE.EXE") Then
If Err.Number = 0 Then
If InStr(objShellWindows.Item(i).Document.Title, (Window)) Then
URLFound = True
Exit For
End If
End If
End If
End If
Next
objIE.Visible = True
objIE.Document.All.Item("idAddNewItemLink").Click
Set objShell = Nothing
Set objShellWindows = Nothing
Set objIE = Nothing
誰能幫助我弄清楚如何設置焦點第二張圖片名爲「 - New Item」?我試過了:
Set WShell = CreateObject("WScript.Shell")
WShell.AppActivate " - New Item"
Set WShell = Nothing
這是行不通的。我試過了:
Set WShell = CreateObject("WScript.Shell")
If objIE.Document.Title = " - All Tasks" Then
WShell.AppActivate " - New Item"
End If
Set WShell = Nothing
這也行不通。希望有人有我可以嘗試的解決方案。
所以我會將我的代碼的第一部分複製到列表中,並調用表單的URL和Window標題? – Lou 2014-11-06 21:32:00
如果我明白你在做什麼,那麼是的。 – Robbert 2014-11-06 21:40:09
我想'如果InStr(UCase(objShellWindows.Item(i).LocationURL),UCase(URL))然後'然後程序停止。我複製並粘貼了上面的所有內容,除了我更改了URL和Window之外,它只是停止了。有任何想法嗎? – Lou 2014-11-07 15:02:44