Solved

How to open a Word doc in VBA

Posted on 2014-11-19
3
184 Views
Last Modified: 2014-11-20
Could someone please show me the VBA to to open a word document in MS Office 2010.

Please don't send a web link unless you're sure it will work.  (I've looked on the web.)

Thanks
0
Comment
Question by:CRB1609
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 40454229
Try this in a command click event procedure: Make sure to have a document existing.docs on drive D: or amend related line in code.

   
    Dim objWord As Object
    Dim objDoc As Object
    'Start Word and open a new document
    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    Set objDoc = objWord.Documents.Add
    ' existing doc
    Dim objDoc2 As Object
    Set objDoc2 = objWord.Documents.Add("D:\exising.docx") ' amend if necessary

Open in new window

0
 

Author Closing Comment

by:CRB1609
ID: 40454358
Perfect.  Thank you.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 40454538
Welcome!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question