Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need Macro to remove empty paragraph marks. | Microsoft Word Help | |||
Remove macro but still get dialog box | Microsoft Word Help | |||
Macro to remove drop down form fields after complete? | Microsoft Word Help | |||
how do I write a macro to automatically remove links upon saving? | Microsoft Word Help | |||
How do I remove a macro from the tool bar? | Microsoft Word Help |