使用 VBA 进行 SFTP 上传

发布于 2024-09-19 22:43:55 字数 384 浏览 9 评论 0原文

我需要能够通过 VBA 进行 SFTP。我有一个 Access 程序,可以提取数据并对其进行操作,现在我必须找到一种通过 SFTP 上传 excel 07 文件的方法。

我已经在网上找了好几天了,但找不到任何东西。我在这里看到了类似的主题 如何使用 sftp从 MS Access 数据库模块中?,我很想找到 Mat Nadrofsky,因为他似乎有一个解决方案,我只是无法理解其中任何一个)))))))))))

因此,如果有人可以解释该解决方案的含义或有不同的解决方案 - 我真的很感激 谢谢

i need to be able to SFTP though VBA. I have an Access program that pulls data, manipulates it and now i have to find a way to upload the excel 07 file through SFTP.

i've been looking on the net for days and can't find anything. I saw a similar topic here How to use sftp from within an MS Access database module?, and i'd love to find Mat Nadrofsky, because it seemed like he has a solution, i just cant understand any of it)))))))))))

so if someone can explain what that solution was about or has a different solution - i'd really appreciate it
thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

新一帅帅 2024-09-26 22:43:56

您需要一些在 Access 中工作的 SFTP ActiveX 控件。我知道我们的SFTP控件被一些客户在VBA和Access中使用尤其。

You would need some SFTP ActiveX Control that works in Access. I know that our SFTP control is used by some customers in VBA and in Access in particular.

把梦留给海 2024-09-26 22:43:56

我在 Access 97 中按照以下方式完成此操作:

  1. 购买一个具有可用于 MS Access 的 OCX 的 SFTP 客户端
  2. 编写 VBA 代码以使用 SFTP 控件

在一种特殊情况下,没有 OCX - 只有可执行文件 - 我们必须这样做该批处理文件。

I have done it the following way in Access 97:

  1. Buy a SFTP client that has an OCX that is available to MS Access
  2. Write VBA code to use the SFTP control

In one particular case, there was no OCX - only executable - we had to do a batch file for that one.

在你怀里撒娇 2024-09-26 22:43:55

在您链接的上一个 SO 答案中,Mat Nadrofsky 使用了 sftp 命令行客户端。在此示例中,我的 sftp 客户端是 pscp.exe。该客户端是 PuTTY 工具的一部分:PuTTY 下载页面

我想构建并运行这样的命令,将 example.txt 复制到远程计算机上的主目录:

"C:\Program Files\PuTTY\pscp.exe" -sftp -l hans -pw changeme C:\Access\sample.txt 192.168.1.6:/home/hans/

因此此过程将构建并运行该命令字符串。

Public Sub SftpPut()
    Const cstrSftp As String = """C:\Program Files\PuTTY\pscp.exe"""
    Dim strCommand As String
    Dim pUser As String
    Dim pPass As String
    Dim pHost As String
    Dim pFile As String
    Dim pRemotePath As String

    pUser = "hans"
    pPass = "changeme"
    pHost = "192.168.1.6"
    pFile = "C:\Access\sample.txt"
    pRemotePath = "/home/hans/"

    strCommand = cstrSftp & " -sftp -l " & pUser & " -pw " & pPass & _
        " " & pFile & " " & pHost & ":" & pRemotePath
    Debug.Print strCommand
    Shell strCommand, 1 ' vbNormalFocus '
End Sub

您可能更喜欢 ShellAndWait 而不是 Shell,正如 David Fenton 在评论中建议的那样之前的答案。

In the previous SO answer you linked, Mat Nadrofsky used an sftp command line client. In this example my sftp client is pscp.exe. That client is part of the PuTTY tools: PuTTY Download Page

I want to build and run a command like this to copy sample.txt to my home directory on the remote machine:

"C:\Program Files\PuTTY\pscp.exe" -sftp -l hans -pw changeme C:\Access\sample.txt 192.168.1.6:/home/hans/

So this procedure will build and run that command string.

Public Sub SftpPut()
    Const cstrSftp As String = """C:\Program Files\PuTTY\pscp.exe"""
    Dim strCommand As String
    Dim pUser As String
    Dim pPass As String
    Dim pHost As String
    Dim pFile As String
    Dim pRemotePath As String

    pUser = "hans"
    pPass = "changeme"
    pHost = "192.168.1.6"
    pFile = "C:\Access\sample.txt"
    pRemotePath = "/home/hans/"

    strCommand = cstrSftp & " -sftp -l " & pUser & " -pw " & pPass & _
        " " & pFile & " " & pHost & ":" & pRemotePath
    Debug.Print strCommand
    Shell strCommand, 1 ' vbNormalFocus '
End Sub

You may prefer ShellAndWait instead of Shell, as David Fenton suggested in a comment on the previous answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文