另存为语法和range.select索引语法?
我正在尝试编写一些代码行来选择 Excel 中的范围,但该范围的索引有语法错误,有什么建议吗?另外,我试图将 XML 文件另存为 xlsm 文件,其文件名来自存储在数组中的两个文件名的串联,并且出现类似的错误。有什么建议吗?
Range (Allfiles(index)).select 'Allfiles is an array containing the file names ' type error
Activeworkbooks.saveas "c:\Allfiles(1):&:Allfiles (count).xlsm", fileformat=52 'error
I'm trying to write some lines of codes that select a range in excel but the index to the range has a syntax error any suggestions? Also I'm trying to save a XML file as an xlsm file with file names from the concactenation of two file names stored in an array and is getting a similar error.any suggestions??
Range (Allfiles(index)).select 'Allfiles is an array containing the file names ' type error
Activeworkbooks.saveas "c:\Allfiles(1):&:Allfiles (count).xlsm", fileformat=52 'error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您收到“错误”时,有用的“错误消息”将提示您问题所在。通过阅读此消息并对其采取行动,您可以逐步调试代码。
在 VBA 中指定参数的方法是使用
:=
,而不是=
。让我们更正该问题并再次运行它...它的名称为
ActiveWorkbook
,而不是Activeworkbooks
。让我们更正这个问题并再次运行它...我不能声称确切地知道您正在运行什么操作系统,但考虑到
C:\
,我会假设 Windows 的某种风格。您可能知道:
在 Windows 路径中是非法字符?无论如何,我不确定您要将此文件保存在哪里。我最好的猜测:
至于你的第一行代码,
Range (Allfiles(index)).Select
,我不知道你想在那里做什么。您可能需要阅读 Excel-VBA 的帮助文件以了解Range
的作用。When you get an "error", a useful "error message" will give you a hint as to what the problem is. By reading this message and acting upon it, you can debug your code step by step.
The way to specify arguments in VBA is with
:=
, not=
. Let's correct that and run it again...It's called
ActiveWorkbook
, notActiveworkbooks
. Let's correct that and run it once more...I can't claim to know for sure what OS you're running, but given the
C:\
, I'll assume some flavour of Windows. You may know that:
is an illegal character in paths in Windows?Anyhow, I'm not sure where you're trying to save this file. My best guess:
As for you first line of code,
Range (Allfiles(index)).Select
, I have no clue what you're trying to do there. You may want to read Excel-VBA's help file to learn whatRange
does.