NEW NEW USER 
Author Message
 NEW NEW USER

I want to create a macro that opens a window Ctrl-O,
pauses so I can choose a Data Source (or input box to
type data source document name?), opens the data source
recipient list, pauses and has an input box to type in
the name of the recipient I want selected, filters that
recipient so that it will be the only recipient chosen
(until I choose another recipient) and then merge the
document with the recipient information.


Sun, 03 Apr 2005 22:30:37 GMT  
 NEW NEW USER
Hi Sharon,

All this is possible within VBA but it's not really an easy macro.
You could decide to split this problem into pieces, which would make it easier to write some code. For example one macro that opens the datasource dialog:

-------------------------------------------------------
 Sub ChooseDataSource()
  Dialogs(wdDialogMailMergeOpenDataSource).Show
 End Sub
-------------------------------------------------------

One that opens the dialog where you can specify query options:
-------------------------------------------------------
Sub SetQueryOptions()
  Dialogs(wdDialogMailMergeQueryOptions).Show
End Sub
-------------------------------------------------------

and one that merges the result to a new document
-------------------------------------------------------
 Sub MergeMyDocument()

  With ActiveDocument.MailMerge
    .Destination = wdSendToNewDocument
    .Execute pause:=True
  End With

 End Sub
-------------------------------------------------------

etc.

You can also get example code by recording the actions. See:
Creating a macro with no programming experience using the recorder
http://www.mvps.org/word/FAQs/MacrosVBA/UsingRecorder.htm

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/


Quote:
> I want to create a macro that opens a window Ctrl-O,
> pauses so I can choose a Data Source (or input box to
> type data source document name?), opens the data source
> recipient list, pauses and has an input box to type in
> the name of the recipient I want selected, filters that
> recipient so that it will be the only recipient chosen
> (until I choose another recipient) and then merge the
> document with the recipient information.



Wed, 06 Apr 2005 21:17:56 GMT  
 NEW NEW USER
Hi Sharon,

This was the non-easy part I was talking about ;-)
What you're trying to do is not easy if you want to do it all in one macro. That's the reason I suggested you split the macro in separate ones.
If you run the macros in sequence you can take all the necessary actions without the need of the macro to pause and save the selections you've made.
If - for example - you run the macro that I posted earlier that asks you to select the datasource, the datasource will be set for the current document.
If you run the macro to set the query options, fill the options and press Ok, the options will be set.

If you want to combine this in one macro, it'll a much more complicated macro to create. Since you mention you're not really experienced with VBA (yet), I wouldn't suggest this as one of your first macros.

For more info on the different objects, methods etc that are available in VBA, search the VBA Helpfile. You may need to install this, cause AFAIK it isn't installed in a default installation. Just add it in Control Panel - Software - Microsoft Offic.

Apart from that you may want to read the following article:

Getting to grips with VBA basics in 15 minutes
http://www.mvps.org/word/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

On the same site, there are plenty of examples available on programming Word, you might want to visit:
http://www.mvps.org/word/FAQs/MacrosVBA/

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/


Quote:
> Thanks so much for your reply.  With regard to the
> recording the action with no programming, I tried that,
> but when it came to pausing so I could select one of the
> recipient's names and/or the DataSource document, it
> would not do that.  It is the actual pausing in the macro
> that I am trying to accomplish.  Where do you find
> the "codes" and their meanings in VBA?  I am completely
> lost when I try and use VBA!!!  I have always just done
> as you suggested and recorded the actions.        
> >-----Original Message-----
> >Hi Sharon,

> >All this is possible within VBA but it's not really an
> easy macro.
> >You could decide to split this problem into pieces,
> which would make it easier to write some code. For
> example one macro that opens the datasource dialog:

> >-------------------------------------------------------
> > Sub ChooseDataSource()
> >  Dialogs(wdDialogMailMergeOpenDataSource).Show
> > End Sub
> >-------------------------------------------------------

> >One that opens the dialog where you can specify query
> options:
> >-------------------------------------------------------
> >Sub SetQueryOptions()
> >  Dialogs(wdDialogMailMergeQueryOptions).Show
> >End Sub
> >-------------------------------------------------------

> >and one that merges the result to a new document
> >-------------------------------------------------------
> > Sub MergeMyDocument()

> >  With ActiveDocument.MailMerge
> >    .Destination = wdSendToNewDocument
> >    .Execute pause:=True
> >  End With

> > End Sub
> >-------------------------------------------------------

> >etc.

> >You can also get example code by recording the actions.
> See:
> >Creating a macro with no programming experience using
> the recorder
> >http://www.mvps.org/word/FAQs/MacrosVBA/UsingRecorder.htm

> >Hope this helps,
> >regards,
> >Astrid

> >So that all can benefit from the discussion, please post
> all follow-ups to the newsgroup.
> >Visit the MVP Word FAQ site at http://www.mvps.org/word/



> >> I want to create a macro that opens a window Ctrl-O,
> >> pauses so I can choose a Data Source (or input box to
> >> type data source document name?), opens the data
> source
> >> recipient list, pauses and has an input box to type in
> >> the name of the recipient I want selected, filters
> that
> >> recipient so that it will be the only recipient chosen
> >> (until I choose another recipient) and then merge the
> >> document with the recipient information.
> >.



Sat, 09 Apr 2005 07:40:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. new VB site for new users

2. New VB site for new-users

3. kyduke(kyduke@yahoo.com)'s New Logic - New sorting, New paging method

4. New New New

5. NEW NEW NEW Project...

6. Insert new rec, then pass new identity val back to Access97

7. Don't want new New Word Application

8. Create new Documents / new pages

9. Opening new document without a new window opening

10. New or not New?

11. Dim obj As New Class crt Dim Obj As Class = New Class

12. New Ideas = New Features?

 

 
Powered by phpBB® Forum Software