removing code from a document created via code and save as 
Author Message
 removing code from a document created via code and save as

Hi All

I've a document that has Document_Open code that i'ld like to remove from
the document that is created by this code (if that makes sense).  When i do
a "Save As" i just want to keep the word part not the VBA part.

I can't use a template to create the document (due to the Document
Management System and network setup).

Any ideas?

Cheers
Julie



Tue, 13 Sep 2005 11:25:30 GMT  
 removing code from a document created via code and save as
Hi Julie,

If you save the document as an .RTF file, the code will be stripped from it.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Hi All

> I've a document that has Document_Open code that i'ld like to remove from
> the document that is created by this code (if that makes sense).  When i
do
> a "Save As" i just want to keep the word part not the vba part.

> I can't use a template to create the document (due to the Document
> Management System and network setup).

> Any ideas?

> Cheers
> Julie



Tue, 13 Sep 2005 12:40:42 GMT  
 removing code from a document created via code and save as
Hi Doug

Thanks for the suggestion - however, i need to keep styles, heading levels,
toc, linked & unlinked page numbers etc ... so i'm not sure that rtf
(although i've not done much using rtf) will work for me?

the way i've "worked around it" is to set a variable when the new document
is created and then 1st thing in the Document_Open code is to check the
value of that variable.

This seems to work - but i was hoping for a way you can just save a *.doc
with out the modules & code elements.

Cheers
Julie



Quote:
> Hi Julie,

> If you save the document as an .RTF file, the code will be stripped from
it.

> Please respond to the newsgroups for the benefit of others who may be
> interested.

> Hope this helps
> Doug Robbins - Word MVP


> > Hi All

> > I've a document that has Document_Open code that i'ld like to remove
from
> > the document that is created by this code (if that makes sense).  When i
> do
> > a "Save As" i just want to keep the word part not the vba part.

> > I can't use a template to create the document (due to the Document
> > Management System and network setup).

> > Any ideas?

> > Cheers
> > Julie



Tue, 13 Sep 2005 19:54:50 GMT  
 removing code from a document created via code and save as
Hi Julie,

Well the obvious question is "Why do you have a Document_Open event in the
document in the first place?"

It seems to me that you probably should not have it there.  Tell us why and
what it's doing and we might be able to give you an alternative.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Hi Doug

> Thanks for the suggestion - however, i need to keep styles, heading
levels,
> toc, linked & unlinked page numbers etc ... so i'm not sure that rtf
> (although i've not done much using rtf) will work for me?

> the way i've "worked around it" is to set a variable when the new document
> is created and then 1st thing in the Document_Open code is to check the
> value of that variable.

> This seems to work - but i was hoping for a way you can just save a *.doc
> with out the modules & code elements.

> Cheers
> Julie



> > Hi Julie,

> > If you save the document as an .RTF file, the code will be stripped from
> it.

> > Please respond to the newsgroups for the benefit of others who may be
> > interested.

> > Hope this helps
> > Doug Robbins - Word MVP


> > > Hi All

> > > I've a document that has Document_Open code that i'ld like to remove
> from
> > > the document that is created by this code (if that makes sense).  When
i
> > do
> > > a "Save As" i just want to keep the word part not the vba part.

> > > I can't use a template to create the document (due to the Document
> > > Management System and network setup).

> > > Any ideas?

> > > Cheers
> > > Julie



Wed, 14 Sep 2005 09:17:38 GMT  
 removing code from a document created via code and save as
Hi Doug

I can't use templates due to the document management system in place ...

so i have a document called master.doc - which has a document open event of
a message box that says "do you want to combine the 16 documents now?"  on
pressing Yes - a macro fires, that inserts 16 documents / formats them to
the original style definitions / adds a header in with different page
numbering for different sections / resets the outline numbering back to 1 in
each inserted section / inserts and formats a toc and sets up the footer and
then saves this document as Master2003.doc

However, my problem is that when you open Master2003.doc it fires the same
document_open code ... hence asking if you want to combine the 16 documents
again - of course, the user can (should / must) press NO but i feel this is
ugly.

If you have any suggestions regarding this i would be most happy to hear
them.

Cheers
Julie



Quote:
> Hi Julie,

> Well the obvious question is "Why do you have a Document_Open event in the
> document in the first place?"

> It seems to me that you probably should not have it there.  Tell us why
and
> what it's doing and we might be able to give you an alternative.

> Please respond to the newsgroups for the benefit of others who may be
> interested.

> Hope this helps
> Doug Robbins - Word MVP


> > Hi Doug

> > Thanks for the suggestion - however, i need to keep styles, heading
> levels,
> > toc, linked & unlinked page numbers etc ... so i'm not sure that rtf
> > (although i've not done much using rtf) will work for me?

> > the way i've "worked around it" is to set a variable when the new
document
> > is created and then 1st thing in the Document_Open code is to check the
> > value of that variable.

> > This seems to work - but i was hoping for a way you can just save a
*.doc
> > with out the modules & code elements.

> > Cheers
> > Julie



> > > Hi Julie,

> > > If you save the document as an .RTF file, the code will be stripped
from
> > it.

> > > Please respond to the newsgroups for the benefit of others who may be
> > > interested.

> > > Hope this helps
> > > Doug Robbins - Word MVP


> > > > Hi All

> > > > I've a document that has Document_Open code that i'ld like to remove
> > from
> > > > the document that is created by this code (if that makes sense).
When
> i
> > > do
> > > > a "Save As" i just want to keep the word part not the vba part.

> > > > I can't use a template to create the document (due to the Document
> > > > Management System and network setup).

> > > > Any ideas?

> > > > Cheers
> > > > Julie



Wed, 14 Sep 2005 20:18:39 GMT  
 removing code from a document created via code and save as
Hi Julie

To be honest I've never worked with a DMS (the opportunity would be nice!).
So you're saying that the DMS denies you the opportunity to create a
document based on a user specified template? The DMS's i've briefly seen in
action (very briefly!) at least allowed the user to create a document and
then add it to the DMS.

Anyway, one eay way around the problem is to add a boolean custom document
property to your Master document with a value of True. Test this custom
property in you Document_Open event and if True combine your 16 documents
etc. Then set the custom property to False in the generated document to
that the code is never triggered again. Here's the code:

The following adds a Custom Document Property (Boolean i.e.: it's value is
Yes or No):

    ActiveDocument.CustomDocumentProperties.Add "BuildDoc", _
      False, msoPropertyTypeBoolean, True

To change the value of your Custom Document Property once you have created
it use:

    ActiveDocument.CustomDocumentProperties("BuildDoc").Value = False

To read the value of your Custom Document Property:

    If ActiveDocument.CustomDocumentProperties("BuildDoc").Value Then
        MsgBox "The custom property BuildDoc has a Yes value"
    Else
        MsgBox "The custom property BuildDoc has a No value"
    End If

I wish I knew more about DMS's so that I could provide you with more
insiteful help.

Anyway, I hope this has been of help + Cheers - Peter



Quote:
> Hi Doug

> I can't use templates due to the document management system in place ...

> so i have a document called master.doc - which has a document open event
> of a message box that says "do you want to combine the 16 documents
> now?"  on pressing Yes - a macro fires, that inserts 16 documents /
> formats them to the original style definitions / adds a header in with
> different page numbering for different sections / resets the outline
> numbering back to 1 in each inserted section / inserts and formats a toc
> and sets up the footer and then saves this document as Master2003.doc

> However, my problem is that when you open Master2003.doc it fires the
> same document_open code ... hence asking if you want to combine the 16
> documents again - of course, the user can (should / must) press NO but i
> feel this is ugly.

> If you have any suggestions regarding this i would be most happy to hear
> them.

> Cheers
> Julie



>> Hi Julie,

>> Well the obvious question is "Why do you have a Document_Open event in
>> the document in the first place?"

>> It seems to me that you probably should not have it there.  Tell us why
> and
>> what it's doing and we might be able to give you an alternative.

>> Please respond to the newsgroups for the benefit of others who may be
>> interested.

>> Hope this helps
>> Doug Robbins - Word MVP


>> > Hi Doug

>> > Thanks for the suggestion - however, i need to keep styles, heading
>> levels,
>> > toc, linked & unlinked page numbers etc ... so i'm not sure that rtf
>> > (although i've not done much using rtf) will work for me?

>> > the way i've "worked around it" is to set a variable when the new
> document
>> > is created and then 1st thing in the Document_Open code is to check
>> > the value of that variable.

>> > This seems to work - but i was hoping for a way you can just save a
> *.doc
>> > with out the modules & code elements.

>> > Cheers
>> > Julie



>> > > Hi Julie,

>> > > If you save the document as an .RTF file, the code will be stripped
> from
>> > it.

>> > > Please respond to the newsgroups for the benefit of others who may
>> > > be interested.

>> > > Hope this helps
>> > > Doug Robbins - Word MVP


>> > > > Hi All

>> > > > I've a document that has Document_Open code that i'ld like to
>> > > > remove
>> > from
>> > > > the document that is created by this code (if that makes sense).
> When
>> i
>> > > do
>> > > > a "Save As" i just want to keep the word part not the vba part.

>> > > > I can't use a template to create the document (due to the
>> > > > Document Management System and network setup).

>> > > > Any ideas?

>> > > > Cheers
>> > > > Julie



Wed, 14 Sep 2005 21:11:00 GMT  
 removing code from a document created via code and save as
Hi Peter

This is one DMS you don't want to ever meet down a dark alley :)  it was
designed for interaction between word perfect & groupwise ... now the
company's moved to word 2002 it just doesn't really work that effectively.
Other than that i don't know much about it as i can't find anyone in the
company who does :)

I'm doing basically what you suggested and setting a variable and in the
saved version setting the variable to 1 and testing against that.

Cheers
Julie


Quote:
> Hi Julie

> To be honest I've never worked with a DMS (the opportunity would be
nice!).
> So you're saying that the DMS denies you the opportunity to create a
> document based on a user specified template? The DMS's i've briefly seen
in
> action (very briefly!) at least allowed the user to create a document and
> then add it to the DMS.

> Anyway, one eay way around the problem is to add a boolean custom document
> property to your Master document with a value of True. Test this custom
> property in you Document_Open event and if True combine your 16 documents
> etc. Then set the custom property to False in the generated document to
> that the code is never triggered again. Here's the code:

> The following adds a Custom Document Property (Boolean i.e.: it's value is
> Yes or No):

>     ActiveDocument.CustomDocumentProperties.Add "BuildDoc", _
>       False, msoPropertyTypeBoolean, True

> To change the value of your Custom Document Property once you have created
> it use:

>     ActiveDocument.CustomDocumentProperties("BuildDoc").Value = False

> To read the value of your Custom Document Property:

>     If ActiveDocument.CustomDocumentProperties("BuildDoc").Value Then
>         MsgBox "The custom property BuildDoc has a Yes value"
>     Else
>         MsgBox "The custom property BuildDoc has a No value"
>     End If

> I wish I knew more about DMS's so that I could provide you with more
> insiteful help.

> Anyway, I hope this has been of help + Cheers - Peter



> > Hi Doug

> > I can't use templates due to the document management system in place ...

> > so i have a document called master.doc - which has a document open event
> > of a message box that says "do you want to combine the 16 documents
> > now?"  on pressing Yes - a macro fires, that inserts 16 documents /
> > formats them to the original style definitions / adds a header in with
> > different page numbering for different sections / resets the outline
> > numbering back to 1 in each inserted section / inserts and formats a toc
> > and sets up the footer and then saves this document as Master2003.doc

> > However, my problem is that when you open Master2003.doc it fires the
> > same document_open code ... hence asking if you want to combine the 16
> > documents again - of course, the user can (should / must) press NO but i
> > feel this is ugly.

> > If you have any suggestions regarding this i would be most happy to hear
> > them.

> > Cheers
> > Julie



> >> Hi Julie,

> >> Well the obvious question is "Why do you have a Document_Open event in
> >> the document in the first place?"

> >> It seems to me that you probably should not have it there.  Tell us why
> > and
> >> what it's doing and we might be able to give you an alternative.

> >> Please respond to the newsgroups for the benefit of others who may be
> >> interested.

> >> Hope this helps
> >> Doug Robbins - Word MVP


> >> > Hi Doug

> >> > Thanks for the suggestion - however, i need to keep styles, heading
> >> levels,
> >> > toc, linked & unlinked page numbers etc ... so i'm not sure that rtf
> >> > (although i've not done much using rtf) will work for me?

> >> > the way i've "worked around it" is to set a variable when the new
> > document
> >> > is created and then 1st thing in the Document_Open code is to check
> >> > the value of that variable.

> >> > This seems to work - but i was hoping for a way you can just save a
> > *.doc
> >> > with out the modules & code elements.

> >> > Cheers
> >> > Julie



> >> > > Hi Julie,

> >> > > If you save the document as an .RTF file, the code will be stripped
> > from
> >> > it.

> >> > > Please respond to the newsgroups for the benefit of others who may
> >> > > be interested.

> >> > > Hope this helps
> >> > > Doug Robbins - Word MVP


> >> > > > Hi All

> >> > > > I've a document that has Document_Open code that i'ld like to
> >> > > > remove
> >> > from
> >> > > > the document that is created by this code (if that makes sense).
> > When
> >> i
> >> > > do
> >> > > > a "Save As" i just want to keep the word part not the vba part.

> >> > > > I can't use a template to create the document (due to the
> >> > > > Document Management System and network setup).

> >> > > > Any ideas?

> >> > > > Cheers
> >> > > > Julie



Fri, 16 Sep 2005 20:54:26 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Remove filter via code

2. adding office documents to a folder via code

3. Open Document via Excel vba coding

4. Opening Word-document via code

5. Adding code in an Excel document via automation ?

6. Saving records on a form via code

7. wordXP save document without macro/template code

8. Save document with code

9. Saving a document without the code

10. Create a Stored Procedure for MSDE via code?

11. Creating Records in a Second Table ... via Code

12. Can I Create an MDE file via code?

 

 
Powered by phpBB® Forum Software