当前位置:首页 » 文件管理 » excelvba上传附件

excelvba上传附件

发布时间: 2023-09-20 07:13:09

Ⅰ Excel 怎样用vba实现文件上传ftp服务中

VBA访问FTP进行文件传输的,网络上见到3种方式,用过2种。

一、VBA+DOS批处理的方式,本质上还是通过DOS来进行,有点麻烦,而且运行中会弹出CMD窗口,现在已经不用这种方法了。

VBA写DOS:

OpengetfdForOutputAs#1
Print#1,""
Print#1,"("
Print#1,"echo;openxx.xx.xx.xx"
Print#1,"echo;user"
Print#1,"echo;pwd"
Print#1,"echo;cd""";ftpfdx8;""""
Print#1,"echo;prompt"
Print#1,"echo;dir"
Print#1,"echo;bye"
Print#1,")>""";fdx8;""""
Print#1,

Print#1,"ftp-v-i-s:""";fdx8;"""|find""ftpgroup"">""";folderx8;""""
Print#1,

VBA运行它:

Shell("ftp-v-i-s:"&ftpfile)

二、VBA调用API,具体是basp21.dll

详见http://www.hi-ho.ne.jp/babaq/eng/basp21f.html,说明很详细,有实例

示例如下,比较简单易懂,其中getfile为下载,上传使用putfile就好了。

PrivateSubForm_Load()
DimftpAsObject,rcAsLong,vAsVariant,v2AsVariant
DimctrAsLong
Setftp=CreateObject("basp21.FTP")
ftp.OpenLog"c: emplog.txt"
rc=ftp.Connect("ftp.microsoft.com","anonymous","")
Ifrc=0Then
v=ftp.GetDir("bussys/winnt/winnt-public",2)
IfIsArray(v)Then
ForEachv2Inv
Debug.Printv2
Next
EndIf
v=ftp.GetDir("bussys/winnt/winnt-public")
IfIsArray(v)Then
ForEachv2Inv
Debug.Printv2
Next
EndIf
rc=ftp.GetFile("bussys/winnt/winnt-public/*","c: emp")
EndIf
End
EndSub
热点内容
游戏服务器删了会怎么样 发布:2025-03-15 13:41:42 浏览:164
微商城系统源码 发布:2025-03-15 13:31:32 浏览:593
什么是平算法 发布:2025-03-15 13:18:36 浏览:841
seleniumpython教程 发布:2025-03-15 13:11:19 浏览:625
c语言对前端 发布:2025-03-15 13:04:01 浏览:780
解压粉砖 发布:2025-03-15 12:54:38 浏览:225
qq的账号密码到底是什么 发布:2025-03-15 12:45:48 浏览:765
c语言读取wav 发布:2025-03-15 12:45:44 浏览:560
iphone限制密码忘了怎么办 发布:2025-03-15 12:40:53 浏览:820
如何取消信用卡密码锁 发布:2025-03-15 12:33:34 浏览:909