PDA

View Full Version : mail merge not working


Dean
December 5th 03, 01:18 AM
This is what i get, can any one help?

Private Sub Document_New()
Dim oControls As Office.CommandBarControls
Dim oControl As Office.CommandBarControl

Set oControls = CommandBars("Menu Bar").Controls

Rem Set oControls = CommandBars.Item
(37).Controls '36 is the index for "Menu Bar"
For Each oControl In oControls
If (30007 = oControl.ID) Then GoTo FindTools
Next
Exit Sub

FindTools:
Set oControls = oControl.Controls
For Each oControl In oControls
If ("WksMM" = oControl.Tag) Then GoTo FindMerge
Next
Exit Sub

FindMerge:
Set oControls = oControl.Controls
For Each oControl In oControls
If ("WksDocType" = oControl.Tag) Then GoTo
FindButton
Next
Exit Sub

FindButton:
Dim mm As MailMerge
oControl.Execute
Set mm = ActiveDocument.MailMerge
If mm.MainDocumentType = wdNotAMergeDocument Then
ActiveDocument.Close
End If
End Sub

Sharon F
December 5th 03, 01:18 AM
Mail Merge is an Office feature. If you do not get a response here in the
Windows newsgroups, ask this question in one of the MS Office newsgroups.
http://www.microsoft.com/office/community/default.asp


--
Sharon F
Microsoft MVP, Windows - Shell/User


Dean wrote:
> This is what i get, can any one help?
>
> Private Sub Document_New()
> Dim oControls As Office.CommandBarControls
> Dim oControl As Office.CommandBarControl
>
> Set oControls = CommandBars("Menu Bar").Controls
>
> Rem Set oControls = CommandBars.Item
> (37).Controls '36 is the index for "Menu Bar"
> For Each oControl In oControls
> If (30007 = oControl.ID) Then GoTo FindTools
> Next
> Exit Sub
>
> FindTools:
> Set oControls = oControl.Controls
> For Each oControl In oControls
> If ("WksMM" = oControl.Tag) Then GoTo FindMerge
> Next
> Exit Sub
>
> FindMerge:
> Set oControls = oControl.Controls
> For Each oControl In oControls
> If ("WksDocType" = oControl.Tag) Then GoTo
> FindButton
> Next
> Exit Sub
>
> FindButton:
> Dim mm As MailMerge
> oControl.Execute
> Set mm = ActiveDocument.MailMerge
> If mm.MainDocumentType = wdNotAMergeDocument Then
> ActiveDocument.Close
> End If
> End Sub

Google