未经许可的文件复制

问题描述 投票:-1回答:1

您好,我希望能够在没有权限的情况下将excel文件复制到文件夹中。

Sub CopyFile()
Dim Folder As String, FileSource As String, FileTarget As String
Folder = "W:\BusIntegration\" & "\"
FileSource = Folder & "excel.xlsx"
FileTarget = "W:\branch\excel.xlsx"
FileCopy FileSource, FileTarget
End Sub

W:\ branch要求具有访问权限

感谢您的帮助

vba access-vba
1个回答
0
投票

权限被拒绝错误通常是文件路径错误,文件正在使用或处于锁定状态的情况。

查看您的代码,Folder变量可能由于双倍\而引起错误

Folder = "W:\BusIntegration\" & "\"
FileSource = Folder & "excel.xlsx"

'This will return "W:\BusIntegration\\excel.xlsx"

代替尝试

Folder = "W:\BusIntegration\"
FileSource = Folder & "excel.xlsx"

'This will return "W:\BusIntegration\excel.xlsx"
© www.soinside.com 2019 - 2024. All rights reserved.