Solved

How to open a Word doc in VBA

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now