Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete Macros from Word documents

83 views
Skip to first unread message

Kip Fryman

unread,
Jun 20, 2001, 2:36:03 PM6/20/01
to
Is there any way to automate Word so that you can look at any number of word
documents and automatically permanently remove any macros that exists in
these documents?

Thanks,

Your friend Kip


Howard Kaikow

unread,
Jun 20, 2001, 2:45:52 PM6/20/01
to
You could write a macro to do that.
Before doing so, you'd better make sure that the macros are not needed.

--
Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------
"Kip Fryman" <k...@NOSPAM.com> wrote in message
news:eHc9Hfb#AHA.2016@tkmsftngp03...

Dave Rado

unread,
Jun 20, 2001, 2:45:34 PM6/20/01
to
The simplest way is Save as RTF and then Save as Word document.

Regards

Dave

"Kip Fryman" <k...@NOSPAM.com> wrote in message
news:eHc9Hfb#AHA.2016@tkmsftngp03...

Kip Fryman

unread,
Jun 20, 2001, 2:57:41 PM6/20/01
to
I would but thats just too risky...


"Dave Rado" <dr...@onetel.net.uk> wrote in message
news:eNxsXnb#AHA.2028@tkmsftngp05...

Kip Fryman

unread,
Jun 20, 2001, 2:58:42 PM6/20/01
to
They arn't needed. These are transcriptions and the only Macros would be
virii.

I figure just strip them all to be safe before sending them to the customer.

"Howard Kaikow" <kai...@standards.com> wrote in message
news:#IXLyjb#AHA.2224@tkmsftngp07...

Howard Kaikow

unread,
Jun 20, 2001, 4:17:59 PM6/20/01
to
If they are transcriptions, why send out Word documents?
Send PDF.

--
Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------
"Kip Fryman" <k...@NOSPAM.com> wrote in message

news:eQqpxrb#AHA.1924@tkmsftngp02...

Kip Fryman

unread,
Jun 20, 2001, 4:46:38 PM6/20/01
to
The client wants them as Word documents. Im not about to try and make that
change. :)
These clients are major hospitals and law firms in the United States,
Canada, and Europe.

Kip

"Howard Kaikow" <kai...@standards.com> wrote in message

news:#JdHSXc#AHA.1608@tkmsftngp03...

Jonathan West

unread,
Jun 20, 2001, 6:20:21 PM6/20/01
to
Hi Kip

Take a look at the following article

How can I get access to the Document Properties of a Word file without
opening the document?
http://www.mvps.org/word/FAQs/MacrosVBA/DSOFile.htm

One of the properties of a Word document that you can access is "HasMacros".
It is either True or False. For those docs for which it is true, you do the
Save As RTF/Resave as doc routine.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


"Kip Fryman" <k...@NOSPAM.com> wrote in message
news:eHc9Hfb#AHA.2016@tkmsftngp03...

Kip Fryman

unread,
Jun 21, 2001, 9:16:40 AM6/21/01
to
Thanks Jonathan.

I have used the DSOFile application in the past and found the results to be
innacurate. Charachter and line counts were innacurate as well as other
statistics. I am not even sure how reliable the HasMacros property would
be. If its not 100% then there is no point of even considering using it.

Also I cannot save as RTF from a Word doc for obvious reasons. They were
created as Word documents and transforming them to RTF could have bad
ramifications. Im not about to even do that.

Thanks,

Kip


"Jonathan West" <jw...@mvps.org> wrote in message
news:uDtJ$cd#AHA.2020@tkmsftngp03...

Jonathan West

unread,
Jun 21, 2001, 11:29:18 AM6/21/01
to

"Kip Fryman" <k...@NOSPAM.com> wrote in message
news:uWkuTRl#AHA.1440@tkmsftngp05...

> Thanks Jonathan.
>
> I have used the DSOFile application in the past and found the results to
be
> innacurate. Charachter and line counts were innacurate as well as other
> statistics. I am not even sure how reliable the HasMacros property would
> be. If its not 100% then there is no point of even considering using it.

As far as am aware, there is no ptoblem with dsofile. The reason things
like the line count are frequently inaccurate is that Word saves documents
without always updating the statistics.

My use of the HasMacros property has always been reliable.


> Also I cannot save as RTF from a Word doc for obvious reasons. They were
> created as Word documents and transforming them to RTF could have bad
> ramifications. Im not about to even do that.

Again, I haven't had any problems in that direction, with a simple save and
save back. Another Alternative is to use the OrganizerDelete method to
remove any modules. Be aware though that this will not remove the
ThisDocument module if present.

Kip Fryman

unread,
Jun 21, 2001, 3:45:06 PM6/21/01
to
> As far as am aware, there is no ptoblem with dsofile. The reason things
> like the line count are frequently inaccurate is that Word saves documents
> without always updating the statistics.

Yes that seems to be the issue.

> My use of the HasMacros property has always been reliable.

I will have to look into it.

> Again, I haven't had any problems in that direction, with a simple save
and
> save back. Another Alternative is to use the OrganizerDelete method to
> remove any modules. Be aware though that this will not remove the
> ThisDocument module if present.

Actually now that I think about it if it is just a quick save, resave the
document should remain intact. This would not be the case if it was
re-opened as an RTF file. But I wonder if it would remove the Macros right
away or if it would wait until it was reopened as well.....

Thanks again,

Kip


Jonathan West

unread,
Jun 21, 2001, 4:06:42 PM6/21/01
to

"Kip Fryman" <k...@NOSPAM.com> wrote in message
news:eiTqWqo#AHA.1532@tkmsftngp04...

Saving as RTF strips out the macros - RTF has no facility for the macro code
to be stored in the document. Therefore a save & resave is guaranteed to get
rid of any macros.

Kip Fryman

unread,
Jun 22, 2001, 9:30:32 AM6/22/01
to
Have you used this technique?

How has at worked for you?

How many documents have you applied this on?

Does this run in an unattended fashion?

"Jonathan West" <jw...@mvps.org> wrote in message

news:ucH0u7w#AHA.1712@tkmsftngp05...

Mark Tangard

unread,
Jun 22, 2001, 11:39:22 AM6/22/01
to

Kip,

> Does this run in an unattended fashion?

It'd be a simple matter to write a macro that opens each .DOC file
in a folder (and, optionally, its subfolders) and resaves it in RTF
format. That's probably about as unattended as it gets.

-- Mark Tangard <mtan...@speakeasy.net> ----------------------------
------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

Kip Fryman

unread,
Jun 22, 2001, 1:09:02 PM6/22/01
to
Thanks,

I know how to do it, but I was just wondering what Jonathan's experience
with it was. I currently have an unattended system that I developed that
does things with word files and it would be easy for me to add this as an
optionl componant.

Getting an insight of others past experience is what I was aiming for

"Mark Tangard" <mtan...@speakeasy.net> wrote in message
news:3B3366AA...@speakeasy.net...

Jonathan West

unread,
Jun 22, 2001, 5:06:24 PM6/22/01
to

"Kip Fryman" <k...@NOSPAM.com> wrote in message
news:uFuqt9x#AHA.1604@tkmsftngp03...

> Have you used this technique?

Yes

>
> How has at worked for you?

Take a look at the following article for an example

How can I get access to the Document Properties of a Word file without
opening the document?
http://www.mvps.org/word/FAQs/MacrosVBA/DSOFile.htm

It includes a template that you can download and use which will print
selected properties of all the files in a folder. Adapting that, and
resaving files whose HasMacros property is true is only a few lines of code.

>
> How many documents have you applied this on?

Hundreds

>
> Does this run in an unattended fashion?

Yes

Andrew Gabb

unread,
Jun 22, 2001, 9:40:17 PM6/22/01
to Kip Fryman
I don't like the RTF method either. I'm nervous about the RTF
compatibility with different versions of Word documents.

A more certain way is as follows. I've used this often, but not in
macros.

1. Save the document as a template.
2. Open a document based on the new template.
3. Save the new document with the required name.

Andrew

--
Andrew Gabb
email: ag...@tpgi.com.au Adelaide, South Australia
phone: +61 8 8342-1021, fax: +61 8 8269-3280
-----

Dave Rado

unread,
Jun 23, 2001, 2:57:21 AM6/23/01
to
Hi Andrew

Clever idea. However, each version of Word uses it's own version of RTF; and
I'd be interested to see a sample document that loses formatting when saved
as RTF and back by the same version of Word, as I've not seen one yet; and
like Jonathan, I've saved hundreds.

Regards

Dave

"Andrew Gabb" <ag...@tpgi.com.au> wrote in message
news:3B33F381...@tpgi.com.au...

Howard Kaikow

unread,
Jun 23, 2001, 10:22:42 AM6/23/01
to
There were(are?) documented cases in the KB of roundtripping with RTF.

Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------

"Dave Rado" <dr...@onetel.net.uk> wrote in message

news:eqcqxJ7#AHA.1236@tkmsftngp07...

Dave Rado

unread,
Jun 23, 2001, 11:03:25 AM6/23/01
to
Hi Howard

I can't find any relating to Word 97 and above ... except one about doc ->
html -> rtf failing to maintain picture sizes but as we're not discussing
html, that one's not relevant.

Regards

Dave

"Howard Kaikow" <kai...@standards.com> wrote in message

news:eGyKs###AHA.1288@tkmsftngp07...

Andrew Gabb

unread,
Jun 23, 2001, 10:21:59 PM6/23/01
to
As I said, more nervousness than anything else, born from a lifetime
of bitter experiences.

BTW, does RTF also retain things like document properties and
variables?

Andrew

Jonathan West

unread,
Jun 24, 2001, 6:41:29 AM6/24/01
to

"Andrew Gabb" <ag...@tpgi.com.au> wrote in message
news:3B354EC7...@tpgi.com.au...

> As I said, more nervousness than anything else, born from a lifetime
> of bitter experiences.
>
> BTW, does RTF also retain things like document properties and
> variables?
>

Properties yes, Variables I think no.

Howard Kaikow

unread,
Jun 24, 2001, 8:45:20 AM6/24/01
to
RTF does save document variables, at least it duz in Word 9.

--


Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------

"Jonathan West" <jw...@mvps.org> wrote in message

news:#YqZtyJ$AHA.1108@tkmsftngp05...

Klaus Linke

unread,
Jun 24, 2001, 1:08:04 PM6/24/01
to
Dave Rado write:
>
> Hi Andrew
>
> Clever idea. However, each version of Word uses it's own version of RTF; and
> I'd be interested to see a sample document that loses formatting when saved
> as RTF and back by the same version of Word, as I've not seen one yet; and
> like Jonathan, I've saved hundreds.
>
> Regards
>
> Dave
>


Hi Dave,

I can satisfy your interest <g>
Word 2000;
Run the following macro in an empty document and save as RTF.
The RTF-file will show no trace of the last two accents.
Pretty exotic, but still ... (Suzanne Barnshill brought up these accent marks
a while back; they seem to belong to the far-east support)

ActiveDocument.Paragraphs(1).SpaceBefore = 12
Selection.TypeText "mytest"
ActiveDocument.Characters(1).Font.EmphasisMark = wdEmphasisMarkNone
ActiveDocument.Characters(2).Font.EmphasisMark = wdEmphasisMarkOverComma
ActiveDocument.Characters(3).Font.EmphasisMark = wdEmphasisMarkOverSolidCircle
ActiveDocument.Characters(4).Font.EmphasisMark = wdEmphasisMarkOverWhiteCircle
ActiveDocument.Characters(5).Font.EmphasisMark = wdEmphasisMarkUnderSolidCircle

Greetings, Klaus

Dave Rado

unread,
Jun 24, 2001, 6:52:33 PM6/24/01
to
LOL! Trust you to find something, Klaus! <g> But as you say, it's pretty
exotic.

Regards

Dave

"Klaus Linke" <fotosatz...@t-online.de> wrote in message
news:OyPkz#M$AHA.1336@tkmsftngp07...

Kip Fryman

unread,
Jun 24, 2001, 9:24:38 PM6/24/01
to
Cool

> > How has at worked for you?
>
> Take a look at the following article for an example

Yes Ive already tested it a few months go and still have it.

> >
> > How many documents have you applied this on?
>
> Hundreds

Cool. My program would be doing it on hundreds of files a day.. I am not
sure if this is the route I will take. I am still debating between this
solution or a virus scanning solution.


> > Does this run in an unattended fashion?
>
> Yes

Cool. Thanks again Jonathan


Klaus Linke

unread,
Jul 1, 2001, 7:01:01 PM7/1/01
to
Another example for losing information when saving as RTF (this one is not
quite as exotic; Word2000 again):

SYMBOL-fields get changed by saving as RTF.
{SYMBOL \a 97 \f "Symbol" \s 20} gets changed to a protected character (with
that I mean a character that behaves as if it had been inserted with
"Insert|Symbol": you can't change its font, and MsgBox AscW(Selection) shows
"40"), and the size gets changed from 20 pt to the size of the preceeding character).

Greetings, Klaus

0 new messages