Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Execute macro from word button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex St-Pierre - 19 Mar 2006 18:37 GMT
Hi, I have a macro which execute a mailmerge and modify the document beafter.
I would like to add a macro to Excel that will close excel, open word and
execute the word macro. Does anyone have already done something like that ?
(if the excel workbook close, it stop the macro ?)
Signature

Alex St-Pierre

Helmut Weber - 19 Mar 2006 22:01 GMT
Hi Alex,

after closing Excel there is no way,
to continue an Excel macro, IMHO.

Or close the Excel workbook, which contains the macro.

You may have an Excel macro,
which starts Word,
opens a doc or creates a doc,
does a mailmerge etc.
and then closes Excel.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Alex St-Pierre - 20 Mar 2006 20:00 GMT
Hi Helmut,
Since the main excel workbook from which Macro is executed open a word
mailmerge that is linked to the main document, it ask to close the excel
workbook to be able to set DDE connexion. If I am able to set DDE with
activeworkbook without closing it, it will work good. Do you know how ?

I have pasted here some code I tried:
Sub Execution_MailMerge_From_Excel()
   On Error Resume Next
   Set WdApp = GetObject("", "Word.Application")
   If WdApp Is Nothing Then
       Set WdApp = CreateObject("Word.Application")
   End If
   On Error GoTo 0
Dim WbName as string
WbName = ActiveWorkbook.Name
Set oWordDoc = oWord.Open("C:\mailmerge.doc") 'This ask to close excel..??
Maybe, can I set condition to say: I don't want to open the excel source file
as you can click when you open only "mailmerge.doc" ?
   ActiveDocument.MailMerge.OpenDataSource Name:= _
       WbName, ConfirmConversions:=False, _
       ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
       PasswordDocument:="", PasswordTemplate:="",  
WritePasswordDocument:="", _
       WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
       Connection:="merge", SQLStatement:="", SQLStatement1:="", SubType:= _
       wdMergeSubTypeOther
oWord.macro1 'will execute the first Macro (In excel, I have to put the
Macro in ThisWorkbook to work: is there the same thing in word ?)

End Sub()
Signature

Alex St-Pierre

"Helmut Weber" a écrit :

> Hi Alex,
>
[quoted text clipped - 8 lines]
> does a mailmerge etc.
> and then closes Excel.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.