Stop macro running

J

JB

Hi Folks,
Is there any way I can stop a macro running when I use a file open
dialog to open the template containing the macro?


Public Sub OpenTemplate(bFileSel As Boolean)

On Error Resume Next

With Dialogs(wdDialogFileOpen)
.Name = "*.dot"
If .Display = -1 Then
strTempLoc = WordBasic.FileNameInfo$(.Name, 1) ' file
here has 'macros which seem to kill my app.???
.Execute
End If
If Len(strTempLoc) = 0 Then
MsgBox "You must Select a file"
bFileSel = False
Exit Sub
End If
bFileSel = True
End With

strTempName = ActiveDocument.Name
x = Len(strTempLoc) - Len(strTempName)
strLookPath = Left(strTempLoc, x)

Cheers

J
 
P

Peter Hewett

Hi JB

The helpfully undocumented command that you require is:

' Turn auto macros off
Application.WordBasic.DisableAutoMacros 0

' Turn them back on again
Application.WordBasic.DisableAutoMacros 1

HTH + Cheers - Peter
 
J

JB

Peter said:
Hi JB

The helpfully undocumented command that you require is:

' Turn auto macros off
Application.WordBasic.DisableAutoMacros 0

' Turn them back on again
Application.WordBasic.DisableAutoMacros 1

HTH + Cheers - Peter
Hi Peter,

Thanks for that although you got the 0 & 1 in the wrong place :)

J
 
P

Peter Hewett

Hi JB

Ooops, sorry about that. Thank god for enumerations.

Cheers - Peter

Hi Peter,

Thanks for that although you got the 0 & 1 in the wrong place :)

J

HTH + Cheers - Peter
 

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