Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

How to suppress macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeffery B Paarsa - 20 Sep 2006 00:21 GMT
After displaying Userform and extracting necessary fields from the user thru
Userform by double clicking on a templete X.dot following are the VBA code
that will be executed:

Private Sub CMDPrint_Click()
'  some codes.....
With ActiveDocument
 .Unprotect
 ActiveDocument.Fields.Update
 .Protect wdAllowOnlyFormFields
 NPPkg.Hide
'  .PrintOut
End With
 openMedHistory  ' This will open a new document using a new template...
see next few lines.
End Sub

Sub openMedHistory()
 Word.Documents.Add Template:="G:\ZZZdoc\(ALL)MRPMedHist.dot", Visible:=False
 With ActiveDocument
   .Unprotect
   .Bookmarks("PFName").Range _
   .InsertBefore PFName
   .Bookmarks("PFName").Range.Font.Color = wdColorRed
   .Bookmarks("PLName").Range _
   .InsertBefore PLName
   .Bookmarks("PLName").Range.Font.Color = wdColorRed
   ActiveDocument.Fields.Update
   .Protect wdAllowOnlyFormFields
'  .PrintOut
 End With
End Sub
Signature


When I execute  "openMedHistory" and the line
 Word.Documents.Add Template:="G:\ZZZdoc\(ALL)MRPMedHist.dot", Visible:=False
will be executed it displays the UserForms for this newly added document.  
How can I suppress this macro for the newly added Documents from being
invoked/executed?  Or basically I don't want the the UserForm for this newly
added document to be displayed.    Anybody can help how can I suppress this
macro?
Jeff B Paarsa

Cindy M. - 20 Sep 2006 14:16 GMT
Hi =?Utf-8?B?SmVmZmVyeSBCIFBhYXJzYQ==?=,

> When I execute  "openMedHistory" and the line
>   Word.Documents.Add Template:="G:\ZZZdoc\(ALL)MRPMedHist.dot", Visible:=False
[quoted text clipped - 3 lines]
> added document to be displayed.    Anybody can help how can I suppress this
> macro?

Do any other macros in this document+template combination have to be available
for execution? Which version of Word?

You can use WordBasic.DisableAutoMacros -1 to turn off execution of Auto macros.
But you do have to remember to set it again to 0 to allow them to execute.

If NO macros need to execute you can set the AutomationSecurity to not allow
macros at all (Word 2002/2003).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Jeffery B Paarsa - 21 Sep 2006 17:49 GMT
Hi Cindy,

I am running Word 2003.  I used WordBasic.DisableAutoMacros -1 statement
right before I do Word.Documents.Add.... but I get the following:
Run-time error '438'
Object doesn’t support this property or method.
I downloaded the WordBasic and put it inside of the Office11 folder but
still the same.
Signature

Jeff B Paarsa

> Hi =?Utf-8?B?SmVmZmVyeSBCIFBhYXJzYQ==?=,
>
[quoted text clipped - 22 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
Cindy M. - 22 Sep 2006 10:21 GMT
Hi =?Utf-8?B?SmVmZmVyeSBCIFBhYXJzYQ==?=,

> I am running Word 2003.  I used WordBasic.DisableAutoMacros -1 statement
> right before I do Word.Documents.Add.... but I get the following:
> Run-time error '438'
> Object doesn’t support this property or method.

Ah, my mistake. It's a 1, not -1. See

http://word.mvps.org/faqs/macrosvba/WordBasicCommands.htm

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Jeffery B Paarsa - 21 Sep 2006 17:54 GMT
Sorry I forgot to answer "Do any other macros in this document+template
combination have to be available for execution?"

Answer is No.
Signature

Jeff B Paarsa

> Hi =?Utf-8?B?SmVmZmVyeSBCIFBhYXJzYQ==?=,
>
[quoted text clipped - 22 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.