Our departments are switching from SharePoint 2007 to 2010. The old SharePoints allowed us to use the same URL and Window title for forms, but SharePoint 2010 show the URL and Window title for a list of forms that have been filled out. On that page, there is a link called "Add new item":
To get to a new form, they have to click that link; which brings up a new window with its own title:
Here's the code I have to get to the first image:
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
Can anyone help me figure out how to set the focus for the second image titled " - New Item"? I've tried:
Set WShell = CreateObject("WScript.Shell")
WShell.AppActivate " - New Item"
Set WShell = Nothing
That doesn't work. I've tried:
Set WShell = CreateObject("WScript.Shell")
If objIE.Document.Title = " - All Tasks" Then
WShell.AppActivate " - New Item"
End If
Set WShell = Nothing
That doesn't work either. Hopefully someone has a solution I can try.