Can I open a word document in excel using a macro?

clares

Well-known Member
Joined
Mar 14, 2002
Messages
557
I am sure it can be done but can I open a word document from within excel using a macros attached to a button, if so what is the code? Thank you in advance.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
The following should work OK, but you'll need to set a reference to Word in the VBA editor by clicking on Tools-References and checking the Microsoft Word Object Library, if necessary: -

Dim appWD As Word.Application

Set appWD = CreateObject("Word.Application")
appWD.Documents.Open "C:My DocumentsDocument"
appWD.Visible = True


Change the path to your document path.
 
Upvote 0
Very good but two problems:

1) I had to change
"Dim appWD As Word.Application"
to
"Dim appWD As Application"

2) It always opens a new Word Window weather or not Word is already open and wheather or not the DOC file is already open.

Anyway to avoid problem 2?

Thanks,
Michael
 
Upvote 0
CORRECTION to:
1) I had to change
"Dim appWD As Word.Application"
to
"Dim appWD As Application"

It should have read:
"I had to eliminate it"

Thanks,
Michael
 
Upvote 0

Forum statistics

Threads
1,213,522
Messages
6,114,112
Members
448,549
Latest member
brianhfield

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top