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.

Determine if doc has attached code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tartancli - 05 Sep 2006 17:42 GMT
Hi,
I have a problem wich i hope somebody can help me with. In my Word 2003 COM
Addin, I want to determine if any open documents have associated code. I do
this as follows,

int vbComps = doc.VBProject.VBComponents.Count;

However, if the user has not selected "Trust Access to Visual Basic Project"
macro security setting then any attempt to access VBProject object members
results in an Exception "Programmatic access to Visual Basic Project is not
trusted".

I understand that this security setting is intended to stop virus inserting
code into macros. However, I only want to know if there is code or not. Is
there any way to determine this with this secruty setting?

Thanks in advance
Jezebel - 05 Sep 2006 21:27 GMT
No.

> Hi,
> I have a problem wich i hope somebody can help me with. In my Word 2003
[quoted text clipped - 18 lines]
>
> Thanks in advance
Cindy M. - 06 Sep 2006 13:55 GMT
Hi =?Utf-8?B?dGFydGFuY2xp?=,

> I have a problem wich i hope somebody can help me with. In my Word 2003 COM
> Addin, I want to determine if any open documents have associated code.

One thought does occur to me. If you save the file to XML format, close the
XML then access the file directly you can check for the w:macrosPresent
attribute (either using String functions such as InString or XML). If it's set
to "yes", then there are macros.

(Note: this apparently doesn't work from within Word. If the file is open in
Word the attribute is always "no".)

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 :-)
tartancli - 07 Sep 2006 12:13 GMT
Great suggestion Cindy, i'll check that out. Thanks once again.

> Hi =?Utf-8?B?dGFydGFuY2xp?=,
>
[quoted text clipped - 16 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
 
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.