Solved

How to open a Word doc in VBA

Posted on 2014-11-19
3
183 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

832 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