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
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