I have found that downloading a non-unicode Sharepoint Excel file from VBA using URLDownloadToFile works well. However, if the URL has unicode characters (Chinese) then I see that URLDownloadToFileW is required. However, I have not been able to get it to work. The URL is in the Excel Workbook.FullName.
ex.
ret = URLDownloadToFileW(0, ActiveWorkbook.FullName, sAttachFilename, 0, 0)
In this case, ret is non-0. I have tried:
ret = URLDownloadToFileW(0, StrConv(ActiveWorkbook.FullName,vbUnicode), sAttachFilename, 0, 0)
Same result.
Has anyone been able to download unicode URLs in VBA?
For my situation, the Excel workbook is already downloaded and open. Therefore, there is no need to download it again to a file (ex. directly from Sharepoint). For my requirements, simply executing an ActiveWorkbook.SaveCopyAs method works for me.
Related
Im struggling to resolve an upload problem direct from excel to sharepoint. I have the right permissions and can upload no problem when hardcoding the URL. Issue I have is all the SharePoint URL's are by Project Number and Description for example:
https://teamzzz.sharepoint.com/sites/Projects/NL001%20%20TEST/10.%20Dispatch
The project is called NL001 in this case. Another example of a URL could be:
https://teamzzz.sharepoint.com/sites/Projects/ZNP001%20%20ANOTHERTEST/10.%20Dispatch
Basically at the point of attempting to upload using my Add in I know the first part of the PATH:
https://teamzzz.sharepoint.com/sites/Projects/
The project id I can find from a cell reference:
NL001
The last part of the URL will always be the same as in:
10.%20Dispatch
My problem is the description after NL001 i.e. "%20%20TEST" (see below):
https://teamzzz.sharepoint.com/sites/Projects/NL001%20%20TEST/10.%20Dispatch
Is there anyway I can use some form of wildcard in the URL for example:
https://teamcde.sharepoint.com/sites/Projects/NL001*/10.%20Dispatch
OR
https://teamcde.sharepoint.com/sites/Projects/NL001%/10.%20Dispatch
The above 2 example dont work but was demonstrating the example I require. Here is my code thus far:
Public Sub CommandButton39_Click()
ProjectFileName = Range("B2").Value
SharePointBasePath = "https://teamcde.sharepoint.com/sites/Projects/"
SharePointEndPath = "10.%20Dispatch/"
ActiveWorkbook.SaveAs Filename:=SharePointBasePath & ThisFile & ".xlsm" & SharePointEndPath
End Sub
Is is possible to utilise a wildcard as the description is not known at time of upload.
Thankyou
I am downloading excel files from SharePoint using Python. All works fine except when excel file has special character. below two URLs for reference. I am using URL encoding (import urllib) and works fine for all URLs excepts file has special character. Any idea on what to do?
working fine
_api/web/GetFileByServerRelativeUrl('/sites/11/Documents/C%20F%20D/R%20C%20F%2020200501%20-%20Tecks%20comment.xlsm')/$value
Not working
_api/web/GetFileByServerRelativeUrl('/sites/11/Documents/C%20F%20D/K%20%27%20%27%20-%20%27test.xlsm?')/$value')
file name is -K ' ' - 'test.xlsm
You need to encode all special characters,then use this rest:
/_api/Web/GetFileByServerRelativePath(decodedurl='/sites/dev/Doc/%2520sdff%5E%253d654fd.xlsx')
My file name is:%20sdff^%3d654fd.xlsx
I have the following link:
https://nttdata.atlassian.net/sr/jira.issueviews:searchrequest-csv-current-fields/temp/SearchRequest.csv?jqlQuery=project+%3D+ATHP+AND+issuetype+in+%28story%2C+feature%2C+task%29+AND+Sprint+%3D+1113+AND+%28status+was+not+in++%28DONE%2C+%22BUILD+COMPLETE%22%29+AFTER+%222019%2F01%2F21%22+%29+AND+%28status+was+not+in++%28DONE%2C+%22BUILD+COMPLETE%22%29++BEFORE+%222019%2F01%2F23%22%29&tempMax=1000
Note: It assumes to have an open Jira session for this project. I provided it here in case there is some special character that excel may interpret in a different way.
It executes a Jira Query and downloads the result in a CSV file.
This query is generated by JIRA when trying to export into an excel file the result of the Jira Query Language:
project = ATHP AND issuetype in (story, feature, task) AND
Sprint = 1113 AND (status was not in (DONE, "BUILD COMPLETE") AFTER
"2019/01/21" ) AND (status was not in (DONE, "BUILD COMPLETE")
BEFORE "2019/01/23")
Note: I was trying with a simpler query too based on JIRA request: project = ATHP (search for all issues of project with ID: ATHP) that produce the following query:
https://nttdata.atlassian.net/sr/jira.issueviews:searchrequest-csv-current-fields/temp/SearchRequest.csv?jqlQuery=project+%3DATHP&tempMax=1000
with the same result.
I added as a hyperlink to a cell and when I try to click on the cell, I get the following error:
Unable to open
https://nttdata.atlassian.net/...
Cannot download the information you requested
I thought it may be possible due to the length of the link (396 characters) that has more than 255 characters (see this question), then I created a shortened URL via Bitly, but I get the same error. If I copy and paste the URL directly in Chrome, I get the file downloaded using the original URL or the equivalent Bitly URL.
I also tried to access the hyperlink via VBA script too:
Range("G11").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
But I get the same error.
I have another similar URL created by JIRA that works well as a hyperlink:
https://nttdata.atlassian.net/sr/jira.issueviews:searchrequest-csv-current-fields/39627/SearchRequest-39627.csv?tempMax=1000
One of the differences of this URL is that instead of passing the parameters to the query (JiraQuery) it invokes a filter (saved query) under ID: 39627.
Any suggestion about what is going on here?, for sure there is something in the URL syntax that Excel does not like it, even the navigator accepts it.
I am trying to download Blob file from ORACLE DB. I used dbms_lob.substr to cut binary data on parts (max length of HEX field is 2,000). So I cut it, then I put data into .docx file. When I open it I see the message:
Word found a problem with content in file test777.docx
and asks me to repair the file. After the Office suite repairs, the document just opens fine. I am able to open the document.
The core problem I think in a screenshot:
[![enter image description here][1]][1]
After cutting remained quantity of a symbol of the last field is it is supplemented by '02'. So when I write it in a file and open it with binary view I see lots of spaces in there. As I understand that is a core problem.
[![enter image description here][2]][2]
Does anyone knows how to avoid it? I think the problem in method of downloading.
How to repair bunch of files like Office does? (I have nearly 100 files every month).
You didn't specify a variable name for the length of the blob so I will use BLOB_LENGTH. You need to make sure not to write out more than the full length. Also you do not want the MOD option on the FILE statement since you are creating the file not appending to an existing file.
data _null_;
length fv $ 120;
set blobs;
fv="k:\Folder\"||File_nm;
file writeout FILEVAR=fv recfm=n;
array blob[8] blob_1-blob_8;
do i=1 to 8 ;
len = max(0,min(2000,blob_length - 2000*(i-1)));
put blob[i] $varying2000. len;
end;
run;
I have an Excel file that will be saved as an .csv file for importation into an email automation system. In a function I need to return a piece of HTML code as text.
=IF(A2<0,"CHECKMARK CODE",A2)
The "CHECKMARK CODE" needs to be replaced by:
> < span style="font-size:16px">& #10003;</span>.
For this post, spaces were added to prevent code from display as a checkmark.
However, all my attempts at the format_text function or adding apostrophes only yields errors.
How do I return this as text exactly as needed by the email automation system?
Please try escaping the double quotes:
=IF(A2<0,"<span style=""font-size:16px"">& #10003;</span>",A2)