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 December 5th, 2006, 03:17 PM
ru1 ru1 is offline
Authorized User
Join Date: Feb 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening a Word File Using a Button

Hi everyone. I was wondering if anyone can help me? I want to open a MS Word Document using a button on a form. I am going to build the path and name of the file in code, I just don't know how to invoke MS Word and tell it, "Hey, please go open this file, in this path".

Also, does anyone know if I do this, when the word doc is closed, will it take me back to the access database I was in when we opened the file?


Chuck(Ru1) :)

Old December 6th, 2006, 08:31 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts


   I do the same thing you are talking about here with this code on the on click event of the button:

Dim stLink As String
Dim ctl As CommandButton

stLink = Me.txtFileName
    Set ctl = Me!ButtonName
    With ctl
        .Visible = True
        .HyperlinkAddress = stLink
    End With

The stLink variable gets the path and filename. The Me.ButtonName is the button that has this on click event code.

This should open any kind of document in its associated application based on the extension of the file. So this should work for .doc in Word, .xls in Excel, etc.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Word doc gives logon prompt 531823 VBScript 2 June 26th, 2007 02:54 PM
Opening word document read only in VB StevenVints VB How-To 1 May 3rd, 2006 09:52 AM
Opening Word from ASP arnabghosh Classic ASP Basics 1 December 21st, 2005 10:58 AM
Opening a MS Word document from ASP saturdave Classic ASP Basics 0 May 25th, 2004 01:47 PM
Opening MS-Word M.L.Srinivas Classic ASP Basics 6 November 6th, 2003 08:46 AM

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