Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resend : need help removing user form programatically
Hello,
I do have a spreadsheet in which some VBA code performs some number crunching. When the processing is done, I save the current workbook as a new file. I then want to perform some cleanup on this new file. Basically I need to remove one sheet (code works fine) and I need to remove one userform which contains some code (and this is where my program freezes). Here is the code I am using: ------------------------------------------------------------- Sub CreateConsolidatedReportFile() 'Save consolidated data into separate file 'Open this file and remove the "Process" sheet Dim VBComp As VBComponent ActiveWorkbook.SaveCopyAs TargetFolder & "\Sales Report Consolidated.xls" Set XLApp = CreateObject("Excel.Application") Set XLReport = XLApp.Workbooks.Open(TargetFolder & "\Sales Report Consolidated.xls") Set VBComp = XLReport.VBProject.VBComponents("UserForm1") <======= CODE FREEZES HERE XLApp.Visible = False XLApp.DisplayAlerts = False XLReport.Sheets("Process").Delete XLReport.VBProject.VBComponents.Remove VBComp XLApp.DisplayAlerts = True XLReport.Close SaveChanges:=True XLApp.Quit Set VBComp = Nothing End Sub ------------------------------------------------------------- I wonder if I am using the right approach for this. Any help would be appreciated, Thanks, Xavier |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Removing Module Protection Programatically | Excel Discussion (Misc queries) | |||
Need help removing userform programatically | Excel Programming | |||
Add Checkbox programatically to form | Excel Programming | |||
Removing VBA Code (programatically) | Excel Programming | |||
Removing a user form with code | Excel Programming |