File Size causing issue when saving the Excel File to SharePoint
I have just removed the files embedded in the Excel and that reduced the file size. Then i just uploaded the same file and it worked successfully.
Found an alternate solution for this issue using Excel VBA code
Instead of doing File-->Save & Send-->Save to SharePoint and saving it to the desired SharePoint library.
Public Sub copyToSharePoint(sharepointURL As String, filePath As String)
On Error GoTo errhandler
'Initialize Variables
Dim LlFileLength As Long
Dim Lvarbin() As Byte
Dim LobjXML As Object
Dim LvarBinData As Variant
Dim LstrFileName As String, PstrFullfileName As String, PstrTargetURL As String
Dim fileName As String, lenFileName As Long
'Extract file name
lenFileName = Len(filePath) - InStrRev(filePath, "\")
fileName = Right(filePath, lenFileName)
'Check that the webUrl ends in an "/"
If Right(sharepointURL, 1) <> "/" Then
sharepointURL = sharepointURL & "/"
End If
'**************************** Upload binary files *****************
Set LobjXML = CreateObject("Microsoft.XMLHTTP")
PstrFullfileName = filePath
LlFileLength = FileLen(PstrFullfileName) - 1
' Read the file into a byte array.
ReDim Lvarbin(LlFileLength)
Open PstrFullfileName For Binary As #1
Get #1, , Lvarbin
Close #1
' Convert to variant to PUT.
LvarBinData = Lvarbin
PstrTargetURL = sharepointURL & IDNumber & fileName
' Put the data to the server; false means synchronous.
LobjXML.Open "PUT", PstrTargetURL, False
' Send the file in.
LobjXML.send LvarBinData
Set LobjXML = Nothing
Exit Sub
errhandler:
If Err.Number = 53 Then
MsgBox "Excel was unable to submit the file to SharePoint. " & vbNewLine & _
"Please check that you are not running out of disk space and that no MS Office add-in is causing issues with Excel.", vbCritical, "File Error"
Exit Sub
Else
MsgBox "Your file could not be submitted to SharePoint. The following error occurred:" & vbNewLine & _
"Error " & Err.Number & ": " & Err.Description, vbCritical, "Error Uploading to SharePoint"
Exit Sub
End If
End Sub
September 27th, 2012 5:29am
I am trying to save Excel 2010 to SharePoint 2010 library. I do this from Excel, File-->Save & Send-->Save to SharePoint and saving it to the desired SharePoint library. This works ok if the file size is small. If the file size is more than 5 MB
then i am getting an error "This file contains document properties that have failed custom validation".
Dont go by this error, it is mis-leading. I am able to save the same file to SharePoint library if I reduce the file size by deleting some of the attachments.
Also if i upload the file manually directly from SharePoint site, it is working ok even if the file size is more than 10 MB.
Another point is, I am not facing this problem if i use my test SharePoint site.
Any help is much appreciated!! Thank You!!
Free Windows Admin Tool Kit Click here and download it now
September 30th, 2012 10:11am
How you have confirmed that one of your custom columns is not causing it?
How do you reduce the file size?
If you see the error that you mentioned before (This file contains document properties that have failed custom validation)
that lade me to this assumption.
Please let me know
September 30th, 2012 3:49pm
Is there any custom column in the list or library ? I strongly believe it must be related to the custom field. Please check.
Free Windows Admin Tool Kit Click here and download it now
September 30th, 2012 6:06pm
Unfortunately not, I have checked all the custom columns in the library and it is not causing trouble. The same file which is causing problem, if i reduce the file size and then upload to sharepoint library it is getting uploaded successfully. File-->Save
& Send-->Save to SharePoint and saving it to the desired SharePoint library.
October 1st, 2012 5:02am