Stuart McLachlan
stuart at lexacorp.com.pg
Wed Mar 19 17:31:00 CST 2003
> In my application logic, there is one instance where I want the user to > be directed to a web page. How do I do that through code? In other > words, how do I write code that would do the same thing as if a person > clicked on a hyperlink on the face of the form? > I posted this in response to another question on 10 Oct 2002, but it applies equally well here - The document can be a URL: (Watch for word wrap) You can do it using ShellExecute(). The Sub below will open any registered document type maximized in the foreground, leaving Access maximized behind it. (Other ShowWindow constants are: SW_HIDE = 0 SW_NORMAL = 1 SW_SHOWMINIMIZED = 2 SW_SHOWMAXIMIZED = 3 SW_SHOWNOACTIVATE = 4 SW_SHOWMINNOACTIVE = 7 SW_SHOWDEFAULT = 10 ) Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Sub ShowDocMaximized(DocName As String) Dim ErrorStatus As Long Dim ErrorMessage As String Const SW_MAXIMIZED = 3 If IsNull(docname) Then MsgBox "No Document Name": Exit Sub ErrorStatus = ShellExecute(0, "Open", DocName, "", CurDir$, SW_MAXIMIZED) If ErrorStatus < 33 Then Select Case ErrorStatus Case 0: ErrorMessage = "The operating system is out of memory or resources." Case 2: ErrorMessage = " The specified file was not found." Case 3: ErrorMessage = "The specified path was not found." Case 5: ErrorMessage = "The operating system denied access to the specified file." Case 8: ErrorMessage = "There was not enough memory to complete the operation." Case11: ErrorMessage = "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image)." Case 26: ErrorMessage = "A sharing violation occurred." Case 27: ErrorMessage = "The filename association is incomplete or invalid." Case 29: ErrorMessage = "The DDE transaction failed." Case 28: ErrorMessage = "The DDE transaction could not be completed because the request timed out." Case 30: ErrorMessage = "The DDE transaction could not be completed because other DDE transactions were being processed." Case 31: ErrorMessage = "There is no application associated with the given filename extension." Case 32: ErrorMessage = "The specified dynamic-link library was not found." Case Else: ErrorMessage = "Unidentified Error when opening document" End Select MsgBox ErrorMessage End If End Sub -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support.