通过VBA在受密码保护的网络共享计算机上打开和保存文件

时间:2016-03-24 09:13:47

标签: excel vba excel-vba

我正在使用以下代码在10.42.X.X位置打开并保存文件。如何编写代码以提供用户名和密码来访问此IP机器?

    private void TreeView1_AfterSelect(object sender, TreeViewEventArgs e)
    {
        textBox1.Text = (treeView1.SelectedNode?.Tag as Country)?.Description ?? string.Empty;
    }

1 个答案:

答案 0 :(得分:1)

首先映射位置/驱动器,然后传递用户名和密码变量,如此

Dim objNetwork as Object, persistent as Boolean
persistent = false
set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "drivelettergoeshere:", ""\\10.42.x.x\............", persistent, "username", "password"