' Arguments:
' Title - title of the searchied IE window
' [IsLike] - False/True = exact/partial searching, default is False
' [IsFocus] - False/True = don't_activate/activate IE window, default is False
Function GetIeByTitle(Title, Optional IsLike As Boolean, Optional IsFocus As Boolean) As Object
Dim w As Object
For Each w In CreateObject("Shell.Application").Windows
With w
If .Name = "Windows Internet Explorer" Then
If IsLike Then
If InStr(1, .LocationName, Title, vbTextCompare) > 0 Then ' ZVI:2013-09-10 fixed
' Partial title of window is found - activate IE window
If IsFocus Then
w.Visible = False
w.Visible = True
End If
Set GetIeByTitle = w
Exit For
End If
Else
If StrComp(.LocationName & " - " & .Name, Title, 1) = 0 Then ' ZVI:2013-09-10 fixed
' Title of window is found - activate IE window
If IsFocus Then
w.Visible = False
w.Visible = True
End If
Set GetIeByTitle = w
Exit For
End If
End If
End If
End With
Next
Set w = Nothing
End Function
'---------everything above here sets up rules for the macro---------------------
Sub CreateSFcase()
If IsEmpty(Range("a1")) Then
MsgBox "No. of Bookings is blank" & """", 48
Stop
End If
If IsEmpty(Range("a2")) Then
MsgBox "Dispute Amount is blank" & """", 48
Stop
End If
If IsEmpty(Range("a3")) Then
MsgBox "Transaction Post Date is blank" & """", 48
Stop
End If
If IsEmpty(Range("a4")) Then
MsgBox "Accounting Assigned To is blank" & """", 48
Stop
End If
If IsEmpty(Range("a5")) Then
MsgBox "Contact/Account Lookup Results is blank" & """", 48
Stop
End If
If IsEmpty(Range("a6")) Then
MsgBox "Contact/Account Lookup Results is blank" & """", 48
Stop
End If
If IsEmpty(Range("a7")) Then
MsgBox "Additional To is blank" & """", 48
Stop
End If
'-------------------------------------Everything from to the above green line checks to make sure macro is completely filled out before running the marco---------------------------------------------------------
Dim IE As Object
Dim Title As String
Title = "New Case: Select Case Record Type ~ Salesforce.com - Unlimited Edition"
Set IE = GetIeByTitle(Title, True, True)
If IE Is Nothing Then
MsgBox "Please open the correct Salesforce window" & vbLf & """" & Title & """", 48
Stop
End If
'---------------------------------this pulls up SF---------------------------------------------
End Sub