excel - 关闭未保存的工作簿
问题描述
我正在尝试打开一个包含我打开的数据的(源)文件,将整个工作表移动到我的(目标)工作簿,更改(源)文件的位置,然后关闭(源)文件而不保存任何文件变化。当我使用 .xlsx 源文件时,我对此过程没有任何问题。当我突然将源文件更改为 .csv 时,当我关闭源文件时出现错误提示“运行时错误'-214722080 (800401a8)':自动化错误”在引发错误的行中,我已经还尝试执行“Set src = Workbooks.Close(false, filename)”,这给了我一个错误,说没有关键对象。
fileExists = Dir(filename)
'Checks the above command
If fileExists = "" Then
Exit Sub
End If
'Performance saving
Application.ScreenUpdating = False
'Setting the source workbook to the files from Ignition
Dim src As Workbook
Set src = Workbooks.Open(filename, True, True)
'Pulling in the data from the file and then closing it without saving so the data isn't deleted from the file
src.Sheets(1).Move After:=ThisWorkbook.Sheets("Overview")
'Moves data that is already read in into the archive folder so it doesn't get in the way of future runs
Name filename As path & "Archive\" & newk & "US1Data.csv"
'Closes source workbook after its been moved, line that causes error
src.Close savechanges:=False
解决方案
推荐阅读
- angular - 使用多种配置构建应用程序
- elasticsearch - 使用 Tika 转换提取内容 - Manifold CF
- c# - 哪个表包含列
- php - 日期和时间 --> 选择特定的日历周
- javascript - 如何使 WebStorm 与自定义 JSHint 文件兼容
- html - 由于标题,导航栏 Div 不完全可见
- php - 将 PHP 变量分配给 SQL 的结果
- reactjs - 如何使用 npm localy 在我的 React 应用程序上设置 Bootstrap?
- sql - 根据其他列值进行条件替换
- php - 使用 crons 在 shell 中运行命令是否比执行 laravel 命令消耗更多的服务器资源?