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
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