Check if document is open or closed before running form.

M

malycom

Hi
I have a toolbar menu item that opens a user form where a user can select a
template to use.

I choose to close all documents before running the form which works fine so
long as there is a document open. If there are no documents open and it is
just the Word application itself, it throws an error.

Can you tell me what code to add as a check to this bit of code that will
get this to work.

This is the affected bit of code.

Private Sub UserForm_Initialize()
Documents.Close
With ListBox1
.AddItem "Termination With No Assets"
.AddItem "Blank Letter"
End With
End Sub

Any help is great appreciated.

Thanks in advance

Malcolm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top