Opening a Word Document in Excel
Tonja,
For #1 see the example code below. Be sure to build a
reference to the MS Word Object library via tools.
Sub test()
Dim objWordApp As Word.Application
Dim strFileName As String
Set objWordApp = New Word.Application
objWordApp.Visible = True
strFileName = "c:\temp\test.doc"
objWordApp.Documents.Open strFileName
End Sub
For #2 simply set the property of the worksheet as shown
below.
ActiveWorkbook.Saved = True
If the workbook to be closed is not the active workbook,
then simply set the reference appropriately.
-Tim
-----Original Message-----
Hi -
1. How do I open a specific word document from Excel?
The document is actually mail merged to the excel
spreadsheet (which isn't a problem).
Ex. I have excel doing a loop of about 200 calculations
which stores the information for the word doc. and it
prints off the results. Next, I want the word document
to
open and run through a macro. I have the document to
close each time because I need the original document to
open for each calculation. This is handled through word -
no problem (I already have this programmed). However,
this leads me to my 2nd and final question.
2. How do I keep Excel from prompting me to save? I do
not want to have to hit cancel (about 200 times)
everytime
the document closes.
*****If you can't answer 2 right away, that's okay, but
please help me with #1. I'm in great need of an answer.
XP is the OS.
Thanks so much!!!!!
Tonja
.
|