Guys,
I have this code that I am using to export and import modules into a workbook to be upgraded.
2 things.
1 - This line - Application.Dialogs(xlDialogActivate).Show IS NOT making the selected workbook acitive. I need to do this so I can define TWB as the target workbook
2 - I'm sure I could put a couple of loops in my code to reduce it a bit.
Thanks in advance . .
Bob
Private Sub upgrade() 'Select target workbook Dim TWB As Workbook 'Target Workbook Dim UWB As Workbook 'Upgrade Workbook Dim FName As String 'temp filename for export / import Application.ScreenUpdating = False Set UWB = ActiveWorkbook MsgBox "Please select the Workbook to upgrade" & vbNewLine & "from the following list . . ." & vbNewLine & "(Click OK to show)" Application.Dialogs(xlDialogActivate).Show Set TWB = ActiveWorkbook 'delete existing modules in Target WB Dim VBComp As VBComponent On Error Resume Next With TWB Set VBComp = ThisWorkbook.VBProject.VBComponents("frmsavewr") ThisWorkbook.VBProject.VBComponents.Remove VBComp Set VBComp = ThisWorkbook.VBProject.VBComponents("frmsavecr") ThisWorkbook.VBProject.VBComponents.Remove VBComp Set VBComp = ThisWorkbook.VBProject.VBComponents("Mdl_Sendmail") ThisWorkbook.VBProject.VBComponents.Remove VBComp Set VBComp = ThisWorkbook.VBProject.VBComponents("Mdl_spellcheck") ThisWorkbook.VBProject.VBComponents.Remove VBComp Set VBComp = ThisWorkbook.VBProject.VBComponents("Mdl_Toolbar") ThisWorkbook.VBProject.VBComponents.Remove VBComp End With 'import / export code With UWB FName = .Path & "\code.txt" .VBProject.VBComponents("frmsavewr").Export FName End With TWB.VBProject.VBComponents.Import FName With UWB FName = .Path & "\code.txt" .VBProject.VBComponents("frmsavecr").Export FName End With TWB.VBProject.VBComponents.Import FName With UWB FName = .Path & "\code.txt" .VBProject.VBComponents("Mdl_Sendmail").Export FName End With TWB.VBProject.VBComponents.Import FName With UWB FName = .Path & "\code.txt" .VBProject.VBComponents("Mdl_spellcheck").Export FName End With TWB.VBProject.VBComponents.Import FName With UWB FName = .Path & "\code.txt" .VBProject.VBComponents("Mdl_Toolbar").Export FName End With TWB.VBProject.VBComponents.Import FName Application.ScreenUpdating = True End Sub