gpt4 book ai didi

excel - VBA 有问题。运行时错误 '91' 出现在我身上。任何想法?

转载 作者:行者123 更新时间:2023-12-04 11:44:39 28 4
gpt4 key购买 nike

我正在尝试使用 VBA 解压缩文件,但出现运行时错误 91。这是我的代码:

Dim Destino As String
Dim Origen As String
Dim oAplica As Object

Destino = "C:\Users\Oscar Mayorga\Downloads"
Origen = "C:\Users\Oscar Mayorga\Downloads\PD20210822.zip"
Set oAplica = CreateObject("Shell.Application")
oAplica.Namespace(Destino).CopyHere oAplica.Namespace(Origen).Items

最佳答案

更改Destino = "C:\Users\Oscar Mayorga\DownloadsDestino = "C:\Users\Oscar Mayorga\Downloads\" .还将声明更改为 StringVariant这是你正在尝试的吗?

Dim Destino As Variant
Dim Origen As Variant
Dim oAplica As Object

Destino = "C:\Users\Oscar Mayorga\Downloads\"
Origen = "C:\Users\Oscar Mayorga\Downloads\PD20210822.zip"
Set oAplica = CreateObject("Shell.Application")
oAplica.Namespace(Destino).CopyHere oAplica.Namespace(Origen).Items
解释 : 您正在使用 后期装订 .要理解这一点,请使用 早期装订如下所示。设置对 Microsoft Shell Controls and Automation 的引用来自 Tools | References enter image description here
Option Explicit

Sub Sample()
Dim Destino As Variant
Dim Origen As Variant
Dim oAplica As Shell32.Shell

Destino = "C:\Users\Oscar Mayorga\Downloads\"
Origen = "C:\Users\Oscar Mayorga\Downloads\PD20210822.zip"
Set oAplica = New Shell32.Shell
oAplica.Namespace(Destino).CopyHere oAplica.Namespace(Origen).Items
End Sub
现在,当您在键入 后按空格键时支架 ,你会注意到下面的
enter image description here
它期望 Variant .更多信息可以阅读 Shell.NameSpace method
如果上述链接失效
enter image description here

关于excel - VBA 有问题。运行时错误 '91' 出现在我身上。任何想法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68916094/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com