Dan Waters
dwaters at usinternet.com
Tue Mar 11 12:20:01 CST 2003
Paul, This is the code I've been using. What this does NOT do is move the focus back to the Access Window after Outlook has been opened. That's why I put in a message box to tell the user what to do. You can find the code for FormattedMsgBox on the Trigeminal web site. If anyone knows how to re-display the Access window after Outlook has opened, that sure would be helpful. HTH, Dan Waters ________________________________________________________________________ __________ Private Sub OpenOutlook() On Error GoTo EH Dim objOutlook As Object Dim stgApplication As String '-- Path to Outlook stgApplication = "C:\Program Files\Microsoft Office\Office10\Office10\OUTLOOK.EXE" '-- check to see if Outlook is open. If not then error 429 is raised Set objOutlook = GetObject(, "Outlook.Application") Exit Sub EH: Application.Echo True GlngErrNumber = Err.Number GstgErrDescription = Err.Description Select Case GlngErrNumber Case 429 FormattedMsgBox "Outlook will now open. After it is open move back to QMS.@ @", vbOKOnly, "Open Outlook" Call Shell(stgApplication, 1) Case Else Call GlobalErrors("", GlngErrNumber, GstgErrDescription, CurrentObjectName, "OpenOutlook") End Select End Sub ________________________________________________________________________ __________ -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com] On Behalf Of paul.hartland at fsmail.net Sent: Tuesday, March 11, 2003 8:22 AM To: accessd at databaseadvisors.com; dba-vb at databaseadvisors.com Subject: [AccessD] Opening Outlook if closed code not working To all, Can anyone see why the following code (VB6) would open Outlook even if it is already open, I want a module that when I run my application, it checks to see if Outlook is open if not open it...... Function OpenOutlook() Dim objOut As Object On Error Resume Next Set objOut = GetObject("Outlook.Application") If (Err <> 0) Then Dim strOpenOutlook strOpenOutlook = Shell("D:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\OUTLOOK.EXE", vbMinimizedNoFocus) End If End Function Thanks in advance. Paul ________________________________________________________________________ __ Freeserve AnyTime - Go online whenever you want for just £6.99 a month for your first 3 months, that's HALF PRICE! And then it's just £14.99 a month after that. For more information visit http://www.freeserve.com/time/ or call free on 0800 970 8890 _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com