#1   Report Post  
Posted to microsoft.public.word.docmanagement
Aad Langelaan Aad Langelaan is offline
external usenet poster
 
Posts: 9
Default Remove macro

When I have programmed a .dot file and it is used so to create a .doc file, I
want to have the macro(VBA-code) part removed out of the document so it is a
document only without any vba code in it.
My reason is that you use the programming part to create a document, but
when the document is made, no programming is needed anymore to edit or update
the document. You will not have to answer the macro question also.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Remove macro

Documents created from templates with macros do not contain the macros. The
macros always remain within the template. You may be able to program the
macro to not run a second time e.g. by setting a document variable and only
run the macro according to the state of the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a .doc
file, I want to have the macro(VBA-code) part removed out of the
document so it is a document only without any vba code in it.
My reason is that you use the programming part to create a document,
but when the document is made, no programming is needed anymore to
edit or update the document. You will not have to answer the macro
question also.



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Aad Langelaan Aad Langelaan is offline
external usenet poster
 
Posts: 9
Default Remove macro

Thanks for the solution, but can you tell me how to set that variable.
I have been trying something like "looking" if it is a document what is
opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the macros. The
macros always remain within the template. You may be able to program the
macro to not run a second time e.g. by setting a document variable and only
run the macro according to the state of the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a .doc
file, I want to have the macro(VBA-code) part removed out of the
document so it is a document only without any vba code in it.
My reason is that you use the programming part to create a document,
but when the document is made, no programming is needed anymore to
edit or update the document. You will not have to answer the macro
question also.




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Remove macro

Something like

Dim aVar As Variable
Dim oVars As Variables
Dim iNum As Integer
Set oVars = ActiveDocument.Variables
For Each aVar In oVars
If aVar.name = "varRunMacro" Then iNum = aVar.Index
Next aVar
If iNum = 0 Then
'If variable does not exist - create it and set its value to 1
oVars.Add name:="varRunMacro", Value:=1
End If
'If variable value is 1 then it's a new document, the macro may be run
If oVars("varRunMacro").Value = 1 Then
'do what you want with the document eg
MsgBox "Macro is running"
'set the value of the variable to 0
oVars("varRunMacro").Value = 0
Else 'the macro has been run so the macro may not be run again.
MsgBox "Macro not available"
End If

It may suffice simply to check whether the document has been saved eg

IF Len(ActiveDocument.Path) 0
'do your thing
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Aad Langelaan wrote:
Thanks for the solution, but can you tell me how to set that variable.
I have been trying something like "looking" if it is a document what
is opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the
macros. The macros always remain within the template. You may be
able to program the macro to not run a second time e.g. by setting a
document variable and only run the macro according to the state of
the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a
.doc file, I want to have the macro(VBA-code) part removed out of
the document so it is a document only without any vba code in it.
My reason is that you use the programming part to create a document,
but when the document is made, no programming is needed anymore to
edit or update the document. You will not have to answer the macro
question also.



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Aad Langelaan Aad Langelaan is offline
external usenet poster
 
Posts: 9
Default Remove macro

This works, but not the way I ment to.
the macro security is set to: Medium.
So every time the created doc is started, there is still the question to
enable or disable macro's.
That's what I want to get out of sight.


"Graham Mayor" wrote:

Something like

Dim aVar As Variable
Dim oVars As Variables
Dim iNum As Integer
Set oVars = ActiveDocument.Variables
For Each aVar In oVars
If aVar.name = "varRunMacro" Then iNum = aVar.Index
Next aVar
If iNum = 0 Then
'If variable does not exist - create it and set its value to 1
oVars.Add name:="varRunMacro", Value:=1
End If
'If variable value is 1 then it's a new document, the macro may be run
If oVars("varRunMacro").Value = 1 Then
'do what you want with the document eg
MsgBox "Macro is running"
'set the value of the variable to 0
oVars("varRunMacro").Value = 0
Else 'the macro has been run so the macro may not be run again.
MsgBox "Macro not available"
End If

It may suffice simply to check whether the document has been saved eg

IF Len(ActiveDocument.Path) 0
'do your thing
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Aad Langelaan wrote:
Thanks for the solution, but can you tell me how to set that variable.
I have been trying something like "looking" if it is a document what
is opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the
macros. The macros always remain within the template. You may be
able to program the macro to not run a second time e.g. by setting a
document variable and only run the macro according to the state of
the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a
.doc file, I want to have the macro(VBA-code) part removed out of
the document so it is a document only without any vba code in it.
My reason is that you use the programming part to create a document,
but when the document is made, no programming is needed anymore to
edit or update the document. You will not have to answer the macro
question also.






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Remove macro

Then you need to set Word's macro security to trust installed templates and
addins (or in the case of Word 2007 put the template in a trusted folder
location). There will be no macro prompt then in either case.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
This works, but not the way I ment to.
the macro security is set to: Medium.
So every time the created doc is started, there is still the question
to enable or disable macro's.
That's what I want to get out of sight.


"Graham Mayor" wrote:

Something like

Dim aVar As Variable
Dim oVars As Variables
Dim iNum As Integer
Set oVars = ActiveDocument.Variables
For Each aVar In oVars
If aVar.name = "varRunMacro" Then iNum = aVar.Index
Next aVar
If iNum = 0 Then
'If variable does not exist - create it and set its value to 1
oVars.Add name:="varRunMacro", Value:=1
End If
'If variable value is 1 then it's a new document, the macro may be
run If oVars("varRunMacro").Value = 1 Then
'do what you want with the document eg
MsgBox "Macro is running"
'set the value of the variable to 0
oVars("varRunMacro").Value = 0
Else 'the macro has been run so the macro may not be run again.
MsgBox "Macro not available"
End If

It may suffice simply to check whether the document has been saved eg

IF Len(ActiveDocument.Path) 0
'do your thing
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Aad Langelaan wrote:
Thanks for the solution, but can you tell me how to set that
variable. I have been trying something like "looking" if it is a
document what is opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the
macros. The macros always remain within the template. You may be
able to program the macro to not run a second time e.g. by setting
a document variable and only run the macro according to the state
of the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a
.doc file, I want to have the macro(VBA-code) part removed out of
the document so it is a document only without any vba code in it.
My reason is that you use the programming part to create a
document, but when the document is made, no programming is needed
anymore to edit or update the document. You will not have to
answer the macro question also.



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Aad Langelaan Aad Langelaan is offline
external usenet poster
 
Posts: 9
Default Remove macro

Settings are already so in Word 2003,
but we are not only using templates located at the computer itself, but we
use also
a lot of templates located on network drives.
And the major part of the created documents are also saved on network drives.
So the message still appears.

"Graham Mayor" wrote:

Then you need to set Word's macro security to trust installed templates and
addins (or in the case of Word 2007 put the template in a trusted folder
location). There will be no macro prompt then in either case.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
This works, but not the way I ment to.
the macro security is set to: Medium.
So every time the created doc is started, there is still the question
to enable or disable macro's.
That's what I want to get out of sight.


"Graham Mayor" wrote:

Something like

Dim aVar As Variable
Dim oVars As Variables
Dim iNum As Integer
Set oVars = ActiveDocument.Variables
For Each aVar In oVars
If aVar.name = "varRunMacro" Then iNum = aVar.Index
Next aVar
If iNum = 0 Then
'If variable does not exist - create it and set its value to 1
oVars.Add name:="varRunMacro", Value:=1
End If
'If variable value is 1 then it's a new document, the macro may be
run If oVars("varRunMacro").Value = 1 Then
'do what you want with the document eg
MsgBox "Macro is running"
'set the value of the variable to 0
oVars("varRunMacro").Value = 0
Else 'the macro has been run so the macro may not be run again.
MsgBox "Macro not available"
End If

It may suffice simply to check whether the document has been saved eg

IF Len(ActiveDocument.Path) 0
'do your thing
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Aad Langelaan wrote:
Thanks for the solution, but can you tell me how to set that
variable. I have been trying something like "looking" if it is a
document what is opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the
macros. The macros always remain within the template. You may be
able to program the macro to not run a second time e.g. by setting
a document variable and only run the macro according to the state
of the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a
.doc file, I want to have the macro(VBA-code) part removed out of
the document so it is a document only without any vba code in it.
My reason is that you use the programming part to create a
document, but when the document is made, no programming is needed
anymore to edit or update the document. You will not have to
answer the macro question also.




  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Remove macro

Investigate the use of the Workgroup folder - designed for this type of use.
http://www.gmayor.com/Template_Locations.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
Settings are already so in Word 2003,
but we are not only using templates located at the computer itself,
but we use also
a lot of templates located on network drives.
And the major part of the created documents are also saved on network
drives. So the message still appears.

"Graham Mayor" wrote:

Then you need to set Word's macro security to trust installed
templates and addins (or in the case of Word 2007 put the template
in a trusted folder location). There will be no macro prompt then in
either case.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
This works, but not the way I ment to.
the macro security is set to: Medium.
So every time the created doc is started, there is still the
question to enable or disable macro's.
That's what I want to get out of sight.


"Graham Mayor" wrote:

Something like

Dim aVar As Variable
Dim oVars As Variables
Dim iNum As Integer
Set oVars = ActiveDocument.Variables
For Each aVar In oVars
If aVar.name = "varRunMacro" Then iNum = aVar.Index
Next aVar
If iNum = 0 Then
'If variable does not exist - create it and set its value to 1
oVars.Add name:="varRunMacro", Value:=1
End If
'If variable value is 1 then it's a new document, the macro may be
run If oVars("varRunMacro").Value = 1 Then
'do what you want with the document eg
MsgBox "Macro is running"
'set the value of the variable to 0
oVars("varRunMacro").Value = 0
Else 'the macro has been run so the macro may not be run again.
MsgBox "Macro not available"
End If

It may suffice simply to check whether the document has been saved
eg

IF Len(ActiveDocument.Path) 0
'do your thing
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Aad Langelaan wrote:
Thanks for the solution, but can you tell me how to set that
variable. I have been trying something like "looking" if it is a
document what is opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the
macros. The macros always remain within the template. You may be
able to program the macro to not run a second time e.g. by
setting a document variable and only run the macro according to
the state of the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a
.doc file, I want to have the macro(VBA-code) part removed out
of the document so it is a document only without any vba code
in it. My reason is that you use the programming part to create
a document, but when the document is made, no programming is
needed anymore to edit or update the document. You will not
have to answer the macro question also.



  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Aad Langelaan Aad Langelaan is offline
external usenet poster
 
Posts: 9
Default Remove macro

I do not think, this is a solution.
The organisation I am is to big to get this kind of things accomplished.
Perhaps it is better to leave it be.

thanks anyway.

"Graham Mayor" wrote:

Investigate the use of the Workgroup folder - designed for this type of use.
http://www.gmayor.com/Template_Locations.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
Settings are already so in Word 2003,
but we are not only using templates located at the computer itself,
but we use also
a lot of templates located on network drives.
And the major part of the created documents are also saved on network
drives. So the message still appears.

"Graham Mayor" wrote:

Then you need to set Word's macro security to trust installed
templates and addins (or in the case of Word 2007 put the template
in a trusted folder location). There will be no macro prompt then in
either case.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
This works, but not the way I ment to.
the macro security is set to: Medium.
So every time the created doc is started, there is still the
question to enable or disable macro's.
That's what I want to get out of sight.


"Graham Mayor" wrote:

Something like

Dim aVar As Variable
Dim oVars As Variables
Dim iNum As Integer
Set oVars = ActiveDocument.Variables
For Each aVar In oVars
If aVar.name = "varRunMacro" Then iNum = aVar.Index
Next aVar
If iNum = 0 Then
'If variable does not exist - create it and set its value to 1
oVars.Add name:="varRunMacro", Value:=1
End If
'If variable value is 1 then it's a new document, the macro may be
run If oVars("varRunMacro").Value = 1 Then
'do what you want with the document eg
MsgBox "Macro is running"
'set the value of the variable to 0
oVars("varRunMacro").Value = 0
Else 'the macro has been run so the macro may not be run again.
MsgBox "Macro not available"
End If

It may suffice simply to check whether the document has been saved
eg

IF Len(ActiveDocument.Path) 0
'do your thing
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Aad Langelaan wrote:
Thanks for the solution, but can you tell me how to set that
variable. I have been trying something like "looking" if it is a
document what is opened or a template, but did not succeed in that

"Graham Mayor" wrote:

Documents created from templates with macros do not contain the
macros. The macros always remain within the template. You may be
able to program the macro to not run a second time e.g. by
setting a document variable and only run the macro according to
the state of the variable.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Aad Langelaan wrote:
When I have programmed a .dot file and it is used so to create a
.doc file, I want to have the macro(VBA-code) part removed out
of the document so it is a document only without any vba code
in it. My reason is that you use the programming part to create
a document, but when the document is made, no programming is
needed anymore to edit or update the document. You will not
have to answer the macro question also.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Macro to remove empty paragraph marks. ISay Microsoft Word Help 6 August 4th 08 05:38 PM
Remove macro but still get dialog box Dorci Microsoft Word Help 2 May 10th 07 08:03 PM
Macro to remove drop down form fields after complete? Nabellfl Microsoft Word Help 1 April 18th 07 04:32 PM
how do I write a macro to automatically remove links upon saving? mt_pelion Microsoft Word Help 2 October 9th 06 04:54 PM
How do I remove a macro from the tool bar? mspm45 Microsoft Word Help 2 July 3rd 05 01:16 PM


All times are GMT +1. The time now is 09:26 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"