Hi Schneider_4,
You can use the Windows API to do this. Here's some sample code:
'/ ---------BEGIN CODE---------
Public Const SW_SHOWMAXIMIZED = 3
Public Const ERROR_FILE_NOT_FOUND = 2&
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
Public Function gbOpenDocument(rsFullPath As String, _
rsErrMsg As String) As Boolean
Dim lResponse As Long
lResponse = ShellExecute(Application.hwnd, _
"open" & vbNullChar, rsFullPath & vbNullChar, _
vbNull, vbNull, SW_SHOWMAXIMIZED)
If lResponse = ERROR_FILE_NOT_FOUND Then rsErrMsg _
= "File not found."
gbOpenDocument = (lResponse 32)
End Function
'/ ---------END CODE---------
To use this, just follow these steps:
1) Paste the above code into a Standard Module in the VBE (Alt+F11 to get
there)
2) To open a document, your code would just look something like this:
'/ ---------BEGIN CODE---------
Sub demo()
Dim sErr As String
Dim sPath As String
sPath = "C:\test.gif"
If Not gbOpenDocument(sPath, sErr) Then
MsgBox "Error opening '" & sPath & "': " _
& sErr, vbExclamation, "Error"
End If
End Sub
'/ ---------END CODE---------
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]
Schneider_4 wrote:
Just a warning - I'm not very well versed in VB like this. Here's
what I want to do:
Off of a button in Excel, I want to open a shortcut to another
document (non-office document)which is on my desktop. Let's just say
the document's name is "ABC" for the example. Can someone help me
with what the macro text would look like? TIA -Steve (operating
in XP)