J
Jules
Hi all, Cindy Meister suggested this code to create a list of BBs in a Word document but I keep getting "Compile error variable not defined?" - all the variables seem to be defined? The references seem to be set?
Any ideas please?
Set objBBC = objCat.BuildingBlocks
For i = 1 To objBBC.Count 'Compile error variable not defined?
Set objBB = objBBC(i)
Sub SearchableBuildingBlocksMacro()
'The macro creates a Word document. Each building block in the
'template is inserted on a new page and labeled.
Dim objTemplate As Template
Dim objBBT As BuildingBlockType
Dim objCat As Category
Dim intCount As Integer
Dim intCountCat As Integer
Dim objBB As BuildingBlock
Dim objBBC As BuildingBlocks
Documents.Add
'next line saves in the current default folder on the current drive
ActiveDocument.SaveAs FileName:="SearchableBuildingBlocks.docx"
'change next line to match location on your hard drive
ActiveDocument.AttachedTemplate = "C:\Documents and Settings\docsliveonline.com\Application Data\Microsoft\Document Building Blocks\1033\Building Blocks.dotx"
'repeat macro when done, substituting other building block templates including the Normal template
Set objTemplate = ActiveDocument.AttachedTemplate
For intCount = 1 To objTemplate.BuildingBlockTypes.Count
Set objBBT = objTemplate.BuildingBlockTypes(intCount)
If objBBT.Categories.Count > 0 Then
For intCountCat = 1 To objBBT.Categories.Count
Set objCat = objBBT.Categories(intCountCat)
Set objBBC = objCat.BuildingBlocks
For i = 1 To objBBC.Count 'Compile error variable not defined?
Set objBB = objBBC(i)
Selection.TypeText Text:="Building Block Name:" & vbTab & objBB.Name
Selection.TypeParagraph
Selection.TypeText Text:="Gallery:" & vbTab & objBBT.Name
Selection.TypeParagraph
Selection.TypeText Text:="Category:" & vbTab & objCat.Name
Selection.TypeParagraph
Selection.TypeText Text:="Description (in any):" & vbTab & objBB.Description
Selection.TypeParagraph
objBB.Insert Selection.Range
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Save
Next i
Next intCountCat
End If
Next intCount
ActiveDocument.AttachedTemplate = ""
ActiveDocument.Save
End Sub
Any ideas please?
Set objBBC = objCat.BuildingBlocks
For i = 1 To objBBC.Count 'Compile error variable not defined?
Set objBB = objBBC(i)
Sub SearchableBuildingBlocksMacro()
'The macro creates a Word document. Each building block in the
'template is inserted on a new page and labeled.
Dim objTemplate As Template
Dim objBBT As BuildingBlockType
Dim objCat As Category
Dim intCount As Integer
Dim intCountCat As Integer
Dim objBB As BuildingBlock
Dim objBBC As BuildingBlocks
Documents.Add
'next line saves in the current default folder on the current drive
ActiveDocument.SaveAs FileName:="SearchableBuildingBlocks.docx"
'change next line to match location on your hard drive
ActiveDocument.AttachedTemplate = "C:\Documents and Settings\docsliveonline.com\Application Data\Microsoft\Document Building Blocks\1033\Building Blocks.dotx"
'repeat macro when done, substituting other building block templates including the Normal template
Set objTemplate = ActiveDocument.AttachedTemplate
For intCount = 1 To objTemplate.BuildingBlockTypes.Count
Set objBBT = objTemplate.BuildingBlockTypes(intCount)
If objBBT.Categories.Count > 0 Then
For intCountCat = 1 To objBBT.Categories.Count
Set objCat = objBBT.Categories(intCountCat)
Set objBBC = objCat.BuildingBlocks
For i = 1 To objBBC.Count 'Compile error variable not defined?
Set objBB = objBBC(i)
Selection.TypeText Text:="Building Block Name:" & vbTab & objBB.Name
Selection.TypeParagraph
Selection.TypeText Text:="Gallery:" & vbTab & objBBT.Name
Selection.TypeParagraph
Selection.TypeText Text:="Category:" & vbTab & objCat.Name
Selection.TypeParagraph
Selection.TypeText Text:="Description (in any):" & vbTab & objBB.Description
Selection.TypeParagraph
objBB.Insert Selection.Range
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Save
Next i
Next intCountCat
End If
Next intCount
ActiveDocument.AttachedTemplate = ""
ActiveDocument.Save
End Sub