|
本帖最后由 dxnsjialhd 于 2023-6-15 01:19 编辑
在网上学习了使用URLDownloadToFile下载网页图片的代码。运行也顺利。
但是发现只要图片的网址里面带有中文汉字,就没法正常下载。
求解决方法。。。
以下代码,如果网址是不包含中文的,就可以顺利运行。如果遇到中文汉字的,请教要怎么处理??
------------
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Declare PtrSafe Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Sub url_dowmload()
'下载url链接的文件,保存路径已存在会覆盖文件
Dim URL As String, save_path As String, isdown As Long, fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
URL = "https://images-erp.sursung.com/erp/prod/11389408/4iZTJBSxQX微信截图_20230416133724.png"
save_path = ThisWorkbook.Path & "\" & fso.GetFileName(URL)
isdown = URLDownloadToFile(0, URL, save_path, 0, 0)
End Sub
|
|