Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Open WORD doc from EXCEL using VBA

Working in Office 2003, I have information in an EXCEL file which I can
mailmerge manually into a WORD doc.
I would like to automate this process from a button in the EXCEL file to ask
the user if he wants to view the mailmerged WORD doc. which then goes on to
carry out the mailmerge and display the final result in WORD.
If I want to give the option to print out the WORD doc, does this have to be
part of the EXCEL or the WORD macro?
Any help appreciated.
Yendorian

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Open WORD doc from EXCEL using VBA

If you can write VBA code, it can be done on either sides: in Word, or in
Excel.

From Excel side:

1. Set Reference to Work Object Library in VBA IDE;
2. Start Word and open certain doc file:

Dim wd AS Word.Application
Dim doc As Word.Document
Set wd=New Word.Application
wd.Visibale=True
Set doc=wd.Documents.Open("C:\MyPath\MyDoc.doc)
'do soemthing with the opened document, such as grab data from current
worksheet to update filed/bookmark on document
'Print the doc...
doc.Close True
wd.Quit

From Word side:

1. Set reference to Excel Object Library
2. Start Excel and open certain workbook

Dim xls as Excel.Application
Dim wb As WorkBook
Dim sh As Worksheet

Set xls=New Excel.Application
xls.Visible=True
Set wb=xls.Workbooks.Open("....")
Set sh=wb.Sheet(1) 'Assume the first sheet has needed data
'Get data from the cells on the sheet,
'Update existing doc's field/bookmark
'Print the doc, if needed
Set sh=Nothing
wk.Close Flase
xls.Quit

With latter, you can even get data from Worksheet by using ADO without open
Excel, this makes your code run quicker.


"Yendorian" wrote in message
...
Working in Office 2003, I have information in an EXCEL file which I can
mailmerge manually into a WORD doc.
I would like to automate this process from a button in the EXCEL file to
ask
the user if he wants to view the mailmerged WORD doc. which then goes on
to
carry out the mailmerge and display the final result in WORD.
If I want to give the option to print out the WORD doc, does this have to
be
part of the EXCEL or the WORD macro?
Any help appreciated.
Yendorian


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Word from Excel JT Excel Programming 3 April 19th 07 04:26 AM
Excel Hyperlink doesn't open Word doc the same way as Word does duugg Excel Discussion (Misc queries) 2 October 12th 06 03:14 PM
open word doc from within excel with VBA Luc[_3_] Excel Programming 1 March 20th 05 06:56 PM
Graph Excel Selection, Open Word File, Embed Graph Into Word Steve Excel Programming 0 November 17th 03 05:35 PM
In Excel VBA, open .txt with Word? Ed[_9_] Excel Programming 4 October 30th 03 05:42 PM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"