ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a Word Document in Excel (https://www.excelbanter.com/excel-programming/277192-opening-word-document-excel.html)

Tonja

Opening a Word Document in Excel
 
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

Tim[_22_]

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
.


Tonja McClinton

Opening a Word Document in Excel
 
Thank you very much, Tim.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 04:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com