There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
blue screen blue screen of death boot computer connection crash css dell display driver drivers email error ethernet excel firefox firefox 3 hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem problems router security slow software sound trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Vba: Can A Macro Delete A Module?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
balloon_tom's Avatar
Member with 62 posts.
 
Join Date: Jan 2006
Location: RALEIGH, NC
Experience: Beginner
25-May-2006, 12:58 PM #1
Solved: Vba: Can A Macro Delete A Module?
I have an Excel 2003 PRO workbook whick contains several VBA modules. One of these modules is used as a "startup" program which creates additional worksheets, graphs etc. within the workbook. I call this startup module from a macro in a different module only the first time the workbook is opened. Once this startup module has run, I would like the calling macro to remove this entire starup module from the workbook prior to saving the newly expanded workbook. Is this possible?
Thanks, Tom
OBP's Avatar
OBP OBP is online now
Computer Specs
Distinguished Member with 6,584 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
25-May-2006, 01:44 PM #2
In VBA use the following -

DoCmd.DeleteObject acModule, "module name"
cristobal03's Avatar
Distinguished Member with 2,992 posts.
 
Join Date: Aug 2005
Experience: Advanced
25-May-2006, 01:49 PM #3
I'm not sure that will work. acModule is an Access constant not an Excel constant. Also, the DoCmd object doesn't show up in Excel's object browser. My Excel VBA is really weak though; maybe I'm not looking in the right spot.

chris.
OBP's Avatar
OBP OBP is online now
Computer Specs
Distinguished Member with 6,584 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
26-May-2006, 05:11 AM #4
Chris, you may well be right, I forgot to switch thinking caps. I would think there must be an Excel version though, I will consult my books.
OBP's Avatar
OBP OBP is online now
Computer Specs
Distinguished Member with 6,584 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
26-May-2006, 05:39 AM #5
It looks as if you may be right Chris, Excel's help doesn't mention working with "Modules" at all.
OBP's Avatar
OBP OBP is online now
Computer Specs
Distinguished Member with 6,584 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
26-May-2006, 05:50 AM #6
I was wrong, I found this in Excel 2000 Power Programming

With ActiveWorkbook.VbProject
.VBComponents.Remove . VBComponents("Module1")
End With

to remove module1
balloon_tom's Avatar
Member with 62 posts.
 
Join Date: Jan 2006
Location: RALEIGH, NC
Experience: Beginner
31-May-2006, 04:45 PM #7
Please forgive me folks, I had to go out of town for a few days. This works lika a champ!! Once again YOU FOLKS ROCK!!
Tom
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:38 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.