P
PJ71
Hi All,
I'm am using Ron de Bruin's code to Merge Data from all workbooks in a
folder. The workbooks that I have been merging have been moved onto
sharepoint and I need to update my macro to deal with this. I need to allow
users to browse to the sharepoint folder as the name will change each month.
My attempts to update the code (shown below) allows the user to browse
sharepoint but I can't make a selection until I get to an individual excel
file (and I want to select all files within a folder, including any
subfolders) and then I get an error messsage. (RDB's brilliant code calls on
other macros which I haven't copied here.)
Can anyone help??
Thanks lots
P
Sub ConsolidateDetail()
Dim MyFiles As Variant
Dim myCountOfFiles As Long
Dim oApp As Object
Dim oFolder As Variant
Set oApp = CreateObject("InternetExplorer.Application")
oApp.Visible = True
'Change ScreenUpdating, Calculation and EnableEvents
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
'Browse to the folder
Set oFolder = oApp.BrowseForFolder(0, "Select folder", 512)
If Not oFolder Is Nothing Then
myCountOfFiles = Get_File_Names( _
MyPath:=oFolder.Self.Path, _
Subfolders:=True, _
ExtStr:="*.xl*", _
myReturnedFiles:=MyFiles)
If myCountOfFiles = 0 Then
MsgBox "No files that match the ExtStr in this folder"
Exit Sub
End If
Get_Data _
FileNameInA:=True, _
PasteAsValues:=True, _
SourceShName:="Move", _
SourceShIndex:=1, _
SourceRng:="", _
StartCell:="A27", _
myReturnedFiles:=MyFiles
End If
'Restore ScreenUpdating, Calculation and EnableEvents
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = CalcMode
End With
End Sub
I'm am using Ron de Bruin's code to Merge Data from all workbooks in a
folder. The workbooks that I have been merging have been moved onto
sharepoint and I need to update my macro to deal with this. I need to allow
users to browse to the sharepoint folder as the name will change each month.
My attempts to update the code (shown below) allows the user to browse
sharepoint but I can't make a selection until I get to an individual excel
file (and I want to select all files within a folder, including any
subfolders) and then I get an error messsage. (RDB's brilliant code calls on
other macros which I haven't copied here.)
Can anyone help??
Thanks lots
P
Sub ConsolidateDetail()
Dim MyFiles As Variant
Dim myCountOfFiles As Long
Dim oApp As Object
Dim oFolder As Variant
Set oApp = CreateObject("InternetExplorer.Application")
oApp.Visible = True
'Change ScreenUpdating, Calculation and EnableEvents
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
'Browse to the folder
Set oFolder = oApp.BrowseForFolder(0, "Select folder", 512)
If Not oFolder Is Nothing Then
myCountOfFiles = Get_File_Names( _
MyPath:=oFolder.Self.Path, _
Subfolders:=True, _
ExtStr:="*.xl*", _
myReturnedFiles:=MyFiles)
If myCountOfFiles = 0 Then
MsgBox "No files that match the ExtStr in this folder"
Exit Sub
End If
Get_Data _
FileNameInA:=True, _
PasteAsValues:=True, _
SourceShName:="Move", _
SourceShIndex:=1, _
SourceRng:="", _
StartCell:="A27", _
myReturnedFiles:=MyFiles
End If
'Restore ScreenUpdating, Calculation and EnableEvents
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = CalcMode
End With
End Sub