GS also forgot to edit a copy/paste in the 'Cleanup block of code...
I've added an error handler in case something goes wrong...
Sub GetARMSExport2()
Dim bEventsEnabled As Boolean
Dim vFilename As Variant, vCalcMode As Variant
Dim wksTarget As Worksheet, wkbSource As Workbook
'Dialog parameters
Const sFinfo As String = "All Files (*.*),*.*"
Const sTitle As String = "Select a File to Import"
'Get the vFilename
vFilename = Application.GetOpenvFilename(sFinfo, , sTitle)
'If user cancels
If vFilename = False Then MsgBox "No file was selected.": Exit Sub
With Application
vCalcMode = .Calculation: bEventsEnabled = .EnableEvents
.Calculation = xlCalculationManual: .EnableEvents = False
.ScreenUpdating = False
End With 'Application
On Error GoTo ErrExit
Set wksTarget = ThisWorkbook.Sheets(Get_SheetTabName(ThisWorkbook,
"wksDetails"))
Set wkbSource = Workbooks.Open(vFilename)
ActiveSheet.UsedRange.Copy Destination:=wksTarget.Range("A1")
Application.CutCopyMode = False
' wksTarget.Range("A1").Select '..if necessary
Set wksTarget = ThisWorkbook.Sheets(Get_SheetTabName(ThisWorkbook,
"wksSummary"))
With wksTarget
With .PivotTables("PivotTable4").PivotCache: .Refresh: .Refresh: End With
.Range("A6").Select
End With 'wksTarget
ErrExit:
'Destroy unused objects
Set wksTarget = Nothing: Set wkbSource = Nothing
'Cleanup
With Application
.Calculation = vCalcMode: .EnableEvents = bEventsEnabled:
..ScreenUpdating = True
End With 'Application
End Sub
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion