'Save of Excel file to SharePoint using VB Script fails without an error message
The VB Script below saves an Excel file to SharePoint. According to the SharePoint change history, the save is failing intermittently without generating an error message.
Set xl = CreateObject("Excel.Application")
xl.visible = True
xl.displayalerts = False
Set wb = xl.WorkBooks.open("https://xxxx.sharepoint.com/sites/site name/workbook name.xlsb")
WScript.Sleep 1000
on error resume next
xl.Run MacroName
if err.number <> 0 Then
wscript.echo "Error running macro " & MacroName
xl.quit
wscript.quit
end if
on error goto 0
wb.Save
wb.Close
xl.quit
set xl = Nothing
set wb = Nothing
wscript.echo "Quitting Excel"
wscript.quit
I have captured the output of the script in a file, and the output shows a successful initiation of the script, and just displays the Quitting Excel message.
How can I troubleshoot this -- are there debug messages or code changes that could help me determine the cause and correction of this issue?
Solution 1:[1]
strncpy(text_p, TEXT_P, strlen(TEXT_P)+1); corrupts memory because strlen(TEXT_P)+1 is 14 but you only allocated 10 bytes.
That is the wrong way to use strncpy. The third argument should be number of bytes available in the destination (or less), not the length of the second argument. And you need to ensure the destination in null terminated, because strncpy will not add a terminating null character if it runs into the length limit.
The message “invalid next size” is free reporting it has found its memory to be corrupted.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eric Postpischil |
