Delete Excel Macro Vbscript

Posted on 2013-10-21
Medium Priority
Last Modified: 2013-10-21
I have a vbscript to import an excel macro but I realize that I need to first delete the macro before I import it.  The import script is listed below.  What line do I need to add to delete the macro?

Dim oXL, oBook, oSheet

    ' Create a new instance of Excel and make it visible.
    Set oXL = CreateObject("Excel.Application")
    oXL.Visible = True

    ' Add a new workbook and set a reference to Sheet1.
     Set oBook = oXL.Workbooks.Open(oxL.startuppath & "\Personal.xlsb")
     Set oSheet = oBook.Sheets(1)

    'Import previously created BAS module file
     oXL.VBE.ActiveVBProject.VBComponents.Import "C:\Macros\import\Module1.bas"
Question by:schwientekd
1 Comment
LVL 54

Accepted Solution

Rgonzo1971 earned 2000 total points
ID: 39587999

pls try

     Set VBMod = oXL.VBE.ActiveVBProject.VBComponents("Module1")
     oXL.VBE.ActiveVBProject.VBComponents.Remove VBMod

Open in new window


Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
As a person who answers a lot of questions, I often see code that could be simplified, made easier to read, and perhaps most importantly made easier to maintain if the code was modified to use the Select Case statement. This article explains how to…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question