Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 24th, 2005, 05:51 PM
Registered User
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to open Excel File in Access

I have a database in which the user clicks on a button and it opens a Word document. How would I program Access to open an Excel File instead?


Old January 24th, 2005, 06:08 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Hi Jason,

If the file already exists:

'Call OpenExcelFile("C:\Book1.xls")

Sub OpenExcelFile(strPathToFile As String)
    Dim objXL As Object

    On Error Resume Next

    Set objXL = GetObject(, "Excel.Application")
    Set objXL = GetObject(strPathToFile)

    objXL.Application.Visible = True
    objXL.Parent.Windows(1).Visible = True

End Sub



Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel error cant open file Born2BFree Excel VBA 1 February 20th, 2007 01:05 PM
Open an Excel file using Access, pls help! sunny76 Access VBA 9 June 29th, 2005 02:14 AM
Open File Dialog In Excel XP GT500Shlby Excel VBA 1 June 6th, 2005 09:19 AM
open excel file C# ? npqk VS.NET 2002/2003 2 November 26th, 2004 10:31 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.