Opening & Closing a Browser from a module

pastymann

New member
Local time
Today, 21:36
Joined
Nov 5, 2007
Messages
6
Hi there

I have created a database that I use to auto sms customers. To do this at present I use office automation and create an Excel Application
Set appExcel = GetObject(, "Excel.Application")

I use this to open an Excel Workbook and run a macro within it to send info to the sms gateway, simmilar format to below.
appExcel.Workbooks.Open ("d:\data\repair\cfm15_sms\sms\cfm_sms_texting.xls")

appExcel.Run ("SMSText")

Below is similar to the line in the Excel Workbook
sreply = UserForm1.Inet1.OpenURL("http://www.sms.bt.co.uk/sms/send......

I can then use the following to close the application
appExcel.Quit

What I want to be able to do is drive this all from inside a Access VBA module. I have found a line of code that will allow me to do this
Application.FollowHyperlink "http://www.sms.bt.co.uk/sms/send.....

However, the browser window it opens remains open. This is no good for me.

Is there anyway I can close the browser window opened, or is there a better way of doing it.

Pastymann
 
Solution Found

Thanks Oclaym but the coding was beyond me :o However I have now managed to work out a solution and it is posted below for others to see.

It works well for my Auto SMS program :D


Function IE_Operation()

'IE Application
Dim objexplorer As Object

'Attempt to find an open instance of the Browser
Set objexplorer = GetObject(, "InternetExplorer.Application")

If Err.Number <> 0 Then
'if Browser not open then clear error
Err.Clear
'and open Browser
Set objexplorer = CreateObject("InternetExplorer.Application")
End If

'set the browser window to be invisible
objexplorer.Application.Visible = False

'************************
'Do What You Want Here In VBA
'************************

'quit browser application
objexplorer.Quit

'reset browser application
Set objexplorer = Nothing

End Function


Regards
Pastyman
 

Users who are viewing this thread

Back
Top Bottom