Geacht Forum,
In een macro gebruik ik de volgende code om de meest recente spreadsheet binnen te halen vanaf SharePoint en de huidige spreadsheet te vervangen.
Het blijkt nu dat de macro doorloopt na de regel;
waardoor de SaveAs instructie te vroeg wordt uitgevoerd.
Ik zoek dus iets waarbij de macro wacht todat de file compleet opgehaald is.
mvg,
Aat
In een macro gebruik ik de volgende code om de meest recente spreadsheet binnen te halen vanaf SharePoint en de huidige spreadsheet te vervangen.
Het blijkt nu dat de macro doorloopt na de regel;
Code:
ActiveWorkbook.FollowHyperlink Address:=SharePointUrl & "/" & wbname & ".xlsm"
waardoor de SaveAs instructie te vroeg wordt uitgevoerd.
Ik zoek dus iets waarbij de macro wacht todat de file compleet opgehaald is.
mvg,
Aat
Code:
Sub ttt()
'Replace current workbook with latest version on SharePoint
If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007/2010
FileExtStr = ".xlsm": FileFormatNum = 52
End If
TempFilePath = UCase(Environ$("temp"))
Set wb = ActiveWorkbook
wbpath = UCase(wb.Path)
wbname = Left(wb.Name, InStrRev(wb.Name, ".") - 1)
On Error Resume Next
Kill TempFilePath & "\*.xls"
Kill TempFilePath & "\*.xlsm"
wb.SaveAs TempFilePath & "\" & "temp" & FileExtStr, FileFormat:=FileFormatNum
Kill wbpath & "\" & wbname & ".*"
On Error GoTo errorlog
ActiveWorkbook.FollowHyperlink Address:=SharePointUrl & "/" & wbname & ".xlsm"
Application.CommandBars("Web").Visible = False
ActiveWorkbook.SaveAs wbpath & "\" & wbname & FileExtStr, FileFormat:=FileFormatNum
'Close temp file
wb.Close SaveChanges:=False
End Function