Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Need help removing userform 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 patterns without removing gridlines pennyb9 Excel Discussion (Misc queries) 1 July 11th 07 02:43 AM
Removing Module Protection Programatically Adam Excel Discussion (Misc queries) 8 April 17th 06 05:46 AM
Programatically changing picture in UserForm - VBA - Mac OSX dirk Excel Programming 2 May 14th 04 12:40 PM
Programatically set ref to my DLL ricks Excel Programming 2 April 13th 04 03:08 PM
Removing VBA Code (programatically) Marnie R Excel Programming 1 February 13th 04 01:02 AM


All times are GMT +1. The time now is 09:43 PM.

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"