打开Excel文件进​​行阅读,无需显示VBA [英] Open Excel file for reading with VBA without display

查看:120
本文介绍了打开Excel文件进​​行阅读,无需显示VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过一个宏来搜索现有的Excel文件,但我不想在代码打开时显示这些文件。有没有办法让他们在后台打开,可以这么说?

I want to search through existing Excel files with a macro, but I don't want to display those files when they're opened by the code. Is there a way to have them open "in the background", so to speak?

推荐答案

不知道如果你可以打开他们在当前的excel实例中隐藏

Not sure if you can open them invisibly in the current excel instance

您可以打开一个新的excel实例,隐藏它然后打开工作簿

You can open a new instance of excel though, hide it and then open the workbooks

Dim app as New Excel.Application
app.Visible = False 'Visible is False by default, so this isn't necessary
Dim book As Excel.Workbook
Set book = app.Workbooks.Add(fileName)
'
' Do what you have to do
'
book.Close SaveChanges:=False
app.Quit
Set app = Nothing

正如其他人发布的那样,确保你完成任何已打开的工作簿后清理

As others have posted, make sure you clean up after you are finished with any opened workbooks

这篇关于打开Excel文件进​​行阅读,无需显示VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆