Pages

How to open other office documents from excel

If you happen to have the need to open an office document other than excel (Outlook, Word, PowerPoint or Access) from excel, here is how you do it:


Dim NewApp As Object
Dim NewDoc As Object
    On Error Resume Next

'Substitute "Word.Application" below with the office
'program that you want to use. For example: to open
'an access file use "Access.Application"

    Set NewApp = GetObject(, "Word.Application")
    If NewApp Is Nothing Then
        Set NewApp = CreateObject("Word.Application")
    End If
    On Error GoTo 0 ' resume normal error handling
    With NewApp
        .Visible = True

'Set the file location below to the document that you want to open.

        Set NewDoc = .Documents.Open("C:\Temp\Doc1.docx")
    End With
    Set NewDoc = Nothing
    Set NewApp = Nothing


Make sure that the file that you are trying to open is not already open.


Special thanks to:
erlandsendata

No comments:

Post a Comment

Thanks for leaving a comment.