VBA Word Delete Reference to Template

B

Beate

Hi,

the following Macro disables a menubar in a document, but not in a template
of the document. The problem is, always when the document is closed, a msg
box pops up asking if the user wants to save changes in the template. I would
like to prevent this msg box from popping up.

Does anyone know how to program this? With which command can I delete a
reference?
The code I have is the following:

Private Sub Document_Open()

Dim pruefe As Integer
pruefe = ActiveDocument.Variables.Item("DisableMenu")
If pruefe = "1" Then
'Dokument
'ActiveDocuments.Variables.Item("Template") = ""
ReadInData 'Function of no relevance
DisableMenu False
'CommandBars("File").Controls(5).Enabled = False
End If

End Sub

Thank you for your help.
 
H

Heike Pertzel

Hallo Beate

try it like this:

Dim xx As Object
On Error Resume Next
Set xx = Application.VBE.ActiveVBProject.References.Item("Template")
Application.VBE.ActiveVBProject.References.Remove xx
On Error GoTo 0

Heike Pertzel / DATA 5 GmbH
 

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