Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Module Protection Programatically Adam Excel Discussion (Misc queries) 8 April 17th 06 05:46 AM
Need help removing userform programatically Xavier Excel Programming 0 March 9th 06 03:40 PM
Add Checkbox programatically to form Matt Jensen Excel Programming 4 December 9th 04 05:22 PM
Removing VBA Code (programatically) Marnie R Excel Programming 1 February 13th 04 01:02 AM
Removing a user form with code KimberlyC Excel Programming 1 January 8th 04 11:55 PM


All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"