Thursday, 27 October 2011

Macro to upload excel file to sharepoint

Hi All,
Okay only 30 minutes to log out..within that time was able to come up with a macro which will save an excel sheet to the sharepoint folder. Find below the macro


ActiveWorkbook.SaveAs Filename:= _
        "http://xxxxxxxxxxx.com/teams/analytical/Shared Documents/Test/Sharepoint1.xlsm" _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False


If you want the excel sheet to be saved with the sheet name then below is the macro for it


Sub savesheet()
Dim FSN As String
FSN = ActiveSheet.Name & ".xlsm"
    ActiveWorkbook.SaveAs Filename:= _
        "\\texxxxxxxxxxxxxxxxx\teams\analytical\Shared Documents\Test" & FSN _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
 End Sub



No comments:

Post a Comment