Need help replaceing an userform using an custom addin

white6174

Board Regular
Joined
May 6, 2002
Messages
137
Can someone help

I wrote the following code to replace a userform, (stored the new form in a workbook)

It works fine if I run it from a workbook, the problem is when I save it as an addin and run it through the use of a hot key.

It stops after the workbook with the new form opens.

any ideas thanks
steve w


Sub ReplaceForm()
Dim Filename As Variant
Dim sbook As Variant
Dim VBP As Variant
sbook = ActiveWorkbook.Name

Workbooks.Open Filename:= _
"C:Documents and SettingsaApplication DataMicrosoftAddInsfrmPrint.xls"
Filename = ActiveWorkbook.Path & "tempmodxxx.bas"
ActiveWorkbook.VBProject.VBComponents("frmPrint") _
.Export Filename
Workbooks(sbook).Activate

Set VBP = ActiveWorkbook.VBProject

With VBP.VBComponents
.Remove VBP.VBComponents("frmPrint")
.Import Filename
End With
Windows("frmPrint.xls").Activate
ActiveWindow.Close
' Delete the temorary module file
Kill Filename

End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,144,273
Messages
5,723,436
Members
422,497
Latest member
dougy99

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top