• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Check the existence of a building block by means of VBA

Dear Experts:

this is a snippet from a macro I regularly run:

If the Building Block Entry cannot be found (ie. does not exist), I get an error message that I am trapping with a user-defined message box.

Is it possible to check right right at the beginning of the macro whether this building block exists in the first place and if not, the macro exits right away telling so with a msgbox.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

NormalTemplate.BuildingBlockEntries("MS_BackCover").Insert Where:= _
        Selection.Range, RichText:=True
Andreas Hermle
Andreas Hermle
1 Solution

pls try

On Error Resume Next
Set BB = NormalTemplate.BuildingBlockEntries("MS_BackCover")
On Error goto 0

If Not IsEmpty(BB) Then
 'Your code
End if

Open in new window

Andreas HermleTeam leaderAuthor Commented:
Hi Rgonzo,

great, this did the trick, thank you very much for your great help. I really appreciate it.

Regards, Andreas
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now