S
Sheila D
I have recorded a macro which inserts header & footer & address Autotext
entries but when I try to run it bombs on the first line & comes up with
error 'Run time error 5941 Requested member of the collection does not exist'
My autotext entries are CIMSHeader, CIMSFooter & CIMSAddress - I have no idea
what Plain Number 1 is referring to.....
I don't know anything about VB so no idea what the problem is and any help
much appreciated - code as follows
Sub CIMSInvoice()
'
' CIMSInvoice Macro
'
'
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 1"). _
Insert Where:=Selection.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSHeader").Insert
Where:=Selection. _
Range, RichText:=True
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
NormalTemplate.BuildingBlockEntries("CIMSHeader").Insert
Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 1"). _
Insert Where:=Selection.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSFooter").Insert
Where:=Selection. _
Range, RichText:=True
WordBasic.ViewFooterOnly
NormalTemplate.BuildingBlockEntries("CIMSFooter").Insert
Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 1"). _
Insert Where:=Selection.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSAddress").Insert
Where:=Selection _
.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSAddress").Insert
Where:=Selection _
.Range, RichText:=True
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.TypeBackspace
WordBasic.GoToFooter
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.TypeBackspace
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
entries but when I try to run it bombs on the first line & comes up with
error 'Run time error 5941 Requested member of the collection does not exist'
My autotext entries are CIMSHeader, CIMSFooter & CIMSAddress - I have no idea
what Plain Number 1 is referring to.....
I don't know anything about VB so no idea what the problem is and any help
much appreciated - code as follows
Sub CIMSInvoice()
'
' CIMSInvoice Macro
'
'
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 1"). _
Insert Where:=Selection.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSHeader").Insert
Where:=Selection. _
Range, RichText:=True
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
NormalTemplate.BuildingBlockEntries("CIMSHeader").Insert
Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 1"). _
Insert Where:=Selection.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSFooter").Insert
Where:=Selection. _
Range, RichText:=True
WordBasic.ViewFooterOnly
NormalTemplate.BuildingBlockEntries("CIMSFooter").Insert
Where:=Selection. _
Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 1"). _
Insert Where:=Selection.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSAddress").Insert
Where:=Selection _
.Range, RichText:=True
NormalTemplate.BuildingBlockEntries("CIMSAddress").Insert
Where:=Selection _
.Range, RichText:=True
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.TypeBackspace
WordBasic.GoToFooter
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.TypeBackspace
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub