![]() |
Import macro
I have tried and tried to get a certain macro to work from the Personal
Macro Workbook (PMW). It generates errors. On a lark, I created a module in the current open workbook and pasted the macro there, and deleted it from the PMW. The macro runs perfectly there. Is there a way that I can create a PMW macro that will check to see it such a macro exists in the current workbook and if it doesn't, access a text file that contains the mis-behaving macro and paste it into a module in the current workbook instead? Gene Augustin |
Import macro
Achieving your goal is possible, not necessarily an easy path to follow, but
yes - VBA code can modify other VBA code in certain circumstances. Perhaps the best starting point I can give you is a page on Chip Pearson's web site that discusses this kind of thing. Then you can post back with individual questions regarding where you may have stumped your toe while trying to get this done. Warning: some code changes via VBA code require manually lowering your security shields, so to speak, and so you may not want to keep things going in this fashion all the time. I do have one tool that I use to upgrad normal code modules on customer's systems that might be of use to you. In essence it does what you want it to do - make sure that a particular code module exists in a particular file. It actually doesn't ask "are you there already" - but rather it says, "I've got what you need, now here, TAKE IT! and if you already had it, you've got it again, only newer". Contact me at [remove spaces] HelpFrom @ j lathamsite ..com if you're interested. Just keep in mind, it's not for PMW, but is a stand alone Excel application that requires a touch of setup for the security settings and is run "on demand" by the user. "Gene Augustin" wrote: I have tried and tried to get a certain macro to work from the Personal Macro Workbook (PMW). It generates errors. On a lark, I created a module in the current open workbook and pasted the macro there, and deleted it from the PMW. The macro runs perfectly there. Is there a way that I can create a PMW macro that will check to see it such a macro exists in the current workbook and if it doesn't, access a text file that contains the mis-behaving macro and paste it into a module in the current workbook instead? Gene Augustin |
Import macro
Of course, the real solution here would be to find out why the macro doesn't
work in the PMW but does in the target workbook. I suspect it is using references to some long lost workbook, or worksheets and ranges that don't exist. Was this macro possibly originally a recorded macro rather than one written by a human hand? "Gene Augustin" wrote: I have tried and tried to get a certain macro to work from the Personal Macro Workbook (PMW). It generates errors. On a lark, I created a module in the current open workbook and pasted the macro there, and deleted it from the PMW. The macro runs perfectly there. Is there a way that I can create a PMW macro that will check to see it such a macro exists in the current workbook and if it doesn't, access a text file that contains the mis-behaving macro and paste it into a module in the current workbook instead? Gene Augustin |
All times are GMT +1. The time now is 12:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com