Darkspartan
New Member
- Joined
- Jul 7, 2011
- Messages
- 48
Hi,
This is my first time posting but I have been in vba for about 6 months now.
I am having trouble getting my code to recognize a PDF file that opens in a new IE window. The window is an invoice image that opens when you click a "submit" button.
I currently have code that works with identifying new IE windows, shown below...
Option Explicit
Public WithEvents IE1 As InternetExplorer
Public WithEvents IE2 As InternetExplorer
and
Private Sub IE1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set IE2 = New InternetExplorer
Set ppDisp = IE2.Application
Debug.Print "NewWindow2"
End Sub
This code works on every popup I have come across except for this one I am having trouble with (pdf image).
I have also tried a work around method with the below code, with which I am able to get the pdf image to "quit", or close, but cant get it to print or save. The code cycles through windows until it hits the PDF window.
Public Sub CloseIE()
Dim Shell As Object
Dim AcroPDF As Object
Set Shell = CreateObject("Shell.Application")
For Each AcroPDF In Shell.Windows
If TypeName(AcroPDF.document) = "AcroPDF" Then
AcroPDF.Quit
MsgBox AcroPDF.Name
AcroPDF.Quit
End If
Next
End Sub
The PDF name however is "Microsoft Internet Explorer"
This is my first time posting but I have been in vba for about 6 months now.
I am having trouble getting my code to recognize a PDF file that opens in a new IE window. The window is an invoice image that opens when you click a "submit" button.
I currently have code that works with identifying new IE windows, shown below...
Option Explicit
Public WithEvents IE1 As InternetExplorer
Public WithEvents IE2 As InternetExplorer
and
Private Sub IE1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set IE2 = New InternetExplorer
Set ppDisp = IE2.Application
Debug.Print "NewWindow2"
End Sub
This code works on every popup I have come across except for this one I am having trouble with (pdf image).
I have also tried a work around method with the below code, with which I am able to get the pdf image to "quit", or close, but cant get it to print or save. The code cycles through windows until it hits the PDF window.
Public Sub CloseIE()
Dim Shell As Object
Dim AcroPDF As Object
Set Shell = CreateObject("Shell.Application")
For Each AcroPDF In Shell.Windows
If TypeName(AcroPDF.document) = "AcroPDF" Then
AcroPDF.Quit
MsgBox AcroPDF.Name
AcroPDF.Quit
End If
Next
End Sub
The PDF name however is "Microsoft Internet Explorer"