Solved

How to open a Word doc in VBA

Posted on 2014-11-19
3
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

752 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