![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Portsmouth.UK
Posts: 543
|
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.
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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. |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Posts: 53
|
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 |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Posts: 53
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|