macro changing code in another macro 
Author Message
 macro changing code in another macro

For clarification, I am trying to write a macro to bring
up another macro, and change values in the second, and
save template files automatically as another name. Please
take a look....

ChDir "D:\My Documents\Templates"
    Workbooks.Open Filename:= _
        "D:\My Documents\Templates\Template Geo
Selector.xls"
    Application.Goto Reference:="onetm"

"onetm" is a macro within the file Template Geo
Selector.xls.  The word "Template" may be listed as many
as 29 times in this macro.
HERE, I WANT THE REPLACE THE WORD TEMPLATE, WITH A
CATEGORY NAME, AND THEN SAVE THE FILE AS ANOTHER FILE. As
you can see, I have multiple files I want to do this in,
so any help would be appreciated.

    ChDir "C:\My Documents"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\My Documents\Category Geo Selector.xls",
FileFormat _
        :=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
        False, CreateBackup:=False
    ActiveWindow.Close
ChDir "D:\My Documents\Templates"
    Workbooks.Open Filename:= _
        "D:\My Documents\Templates\Template Time Period
Selector.xls"
    Application.Goto Reference:="map12"

AGAIN, I WANT TO ADD SYNTAX TO CHANGE TEMPLATE TO A
CATEGORY NAME.

    ChDir "C:\My Documents"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\My Documents\Category Time Period
Selector.xls", _
        FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
    ActiveWindow.Close
    ChDir "D:\My Documents\Templates"
    Workbooks.Open Filename:= _
        "D:\My Documents\Templates\Template Time Period
Selector2.xls"
    Application.Goto Reference:="custmap122"

AGAIN, THE SAME

    ChDir "C:\My Documents"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\My Documents\Category Time Period
Selector2.xls", _
        FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
    ActiveWindow.Close
End Sub



Sat, 22 Oct 2005 19:42:31 GMT  
 macro changing code in another macro
I would not recommend using VBA to change code because that might trigger
auntie virus software.

Another approach would be to put the code you wish to change in a separate
Public sub, and pass arguments to that sub to modify the strings you need to
modify.

--
http://www.standards.com/; Howard Kaikow's web site.
------------------------------------------------

Quote:
> For clarification, I am trying to write a macro to bring
> up another macro, and change values in the second, and
> save template files automatically as another name. Please
> take a look....

> ChDir "D:\My Documents\Templates"
>     Workbooks.Open Filename:= _
>         "D:\My Documents\Templates\Template Geo
> Selector.xls"
>     Application.Goto Reference:="onetm"

> "onetm" is a macro within the file Template Geo
> Selector.xls.  The word "Template" may be listed as many
> as 29 times in this macro.
> HERE, I WANT THE REPLACE THE WORD TEMPLATE, WITH A
> CATEGORY NAME, AND THEN SAVE THE FILE AS ANOTHER FILE. As
> you can see, I have multiple files I want to do this in,
> so any help would be appreciated.

>     ChDir "C:\My Documents"
>     ActiveWorkbook.SaveAs Filename:= _
>         "C:\My Documents\Category Geo Selector.xls",
> FileFormat _
>         :=xlNormal, Password:="", WriteResPassword:="",
> ReadOnlyRecommended:= _
>         False, CreateBackup:=False
>     ActiveWindow.Close
> ChDir "D:\My Documents\Templates"
>     Workbooks.Open Filename:= _
>         "D:\My Documents\Templates\Template Time Period
> Selector.xls"
>     Application.Goto Reference:="map12"

> AGAIN, I WANT TO ADD SYNTAX TO CHANGE TEMPLATE TO A
> CATEGORY NAME.

>     ChDir "C:\My Documents"
>     ActiveWorkbook.SaveAs Filename:= _
>         "C:\My Documents\Category Time Period
> Selector.xls", _
>         FileFormat:=xlNormal, Password:="",
> WriteResPassword:="", _
>         ReadOnlyRecommended:=False, CreateBackup:=False
>     ActiveWindow.Close
>     ChDir "D:\My Documents\Templates"
>     Workbooks.Open Filename:= _
>         "D:\My Documents\Templates\Template Time Period
> Selector2.xls"
>     Application.Goto Reference:="custmap122"

> AGAIN, THE SAME

>     ChDir "C:\My Documents"
>     ActiveWorkbook.SaveAs Filename:= _
>         "C:\My Documents\Category Time Period
> Selector2.xls", _
>         FileFormat:=xlNormal, Password:="",
> WriteResPassword:="", _
>         ReadOnlyRecommended:=False, CreateBackup:=False
>     ActiveWindow.Close
> End Sub



Wed, 26 Oct 2005 22:50:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. macro to change code in another macro

2. How to make changes in macros with help of anather macro

3. macro code to replace value in another macro

4. Bulk changing of macros to code

5. Changing macro actions using DAO/VBA code

6. Macro/VBA Code for changing the cell shade color

7. Macro to change text, also changes font size.

8. macro box pops up when no macros exist

9. Word Macro runs then gets Macro Not Found

10. Removing the [ENABLE MACROS] [DISABLE MACROS] popup window

11. Word 97 Macros > Word XP Macros

12. MACROS: copying macro from one PC to another

 

 
Powered by phpBB® Forum Software