简体   繁体   English

如何在不提示输入目的地的情况下打开 IQY 文件?

[英]How can I open an IQY file without being prompted for a destination?

I am automating a process where I open several IQY files and paste them into a master worksheet in excel.我正在自动化一个过程,我打开几个 IQY 文件并将它们粘贴到 Excel 中的主工作表中。 Currently the process is manual.目前该过程是手动的。

I can open the files using VBA, for example:我可以使用 VBA 打开文件,例如:

set sourcebook = workbooks.open("C:\Metrics\sourceFile.iqy")

I've set notifications to false, I've set displayAlerts to false, neither deter the prompt to import data user form.我已将通知设置为 false,我已将 displayAlerts 设置为 false,都不会阻止导入数据用户表单的提示。 I don't change the settings at all, it's currently set to output the data in a table in a new workbook, which is fine.我根本不更改设置,它当前设置为在新工作簿的表中输出数据,这很好。 I just want to remove that decision/click from the process so all I have to do is run the macro and then all the new data is in my master sheet.我只想从流程中删除那个决定/点击,所以我所要做的就是运行宏,然后所有新数据都在我的主表中。

Are there modifiers to the .open method that would allow me to pre-determine things like putting the data in a table on a new workbook? .open 方法是否有修饰符可以让我预先确定诸如将数据放在新工作簿上的表中之类的事情?

I've considered adding the IQY files as a data source, but I have to send/share this file to many other users who will have no use for those files and also I'm not entirely familiar with adding data sources/connects to be honest.我已经考虑将 IQY 文件添加为数据源,但我必须将此文件发送/共享给许多其他用户,这些用户对这些文件没有用处,而且我对添加数据源/连接也不完全熟悉诚实的。

See the "Using a Dynamic Web Query" section in this link https://msdn.microsoft.com/en-us/library/office/aa203721(v=office.11).aspx请参阅此链接中的“使用动态 Web 查询”部分https://msdn.microsoft.com/en-us/library/office/aa203721(v=office.11​​).aspx

This works for me:这对我有用:

Sub Finder_Get_Query()
    'Edit path to .iqy file, if necessary.
    IQYFile = "C:\Program Files\Microsoft Office\OFFICE11\" & _
       "QUERIES\MSN MoneyCentral Investor Currency Rates.iqy"
    With ActiveSheet.QueryTables.Add(Connection:= _
       "FINDER;" & IQYFile, Destination:=Range("A1"))

        .BackgroundQuery = True
        .TablesOnlyFromHTML = True
        .Refresh BackgroundQuery:=False
        .SaveData = True
    End With
End Sub

Works perfect!工作完美! With few modifications you can define the target Sheet for the import (in case you have more than one *.IQY file to connect)只需稍加修改,您就可以定义导入的目标工作表(以防您有多个 *.IQY 文件要连接)

strTargetSheet = "Your SheetName" strTargetSheet = "您的工作表名称"

StrSourceConnection = "Your IQY file location" StrSourceConnection = "您的 IQY 文件位置"

make the call from any other procedure ....从任何其他程序进行调用....

Call Finder_Get_Query(strTargetSheet, strSourceConnection)调用 Finder_Get_Query(strTargetSheet, strSourceConnection)

Sub Finder_Get_Query(strSheet As String, strConnection As String)
Dim IQYFile As String

ThisWorkbook.Sheets(strSheet).Select
 
IQYFile = strConnection
With ActiveSheet.QueryTables.Add(Connection:= _
   "FINDER;" & IQYFile, Destination:=Range("A1"))

    .BackgroundQuery = True
    .TablesOnlyFromHTML = True
    .Refresh BackgroundQuery:=False
    .SaveData = True
End With
End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不提示替换(空)目标单元格(EPPlus)的内容的情况下将图像添加到工作表中? - How can I add an image to my sheet without being prompted to replace contents of the (empty) destination cells (EPPlus)? 如何在没有提示的情况下从 VBScript 关闭 Excel 文件? - How to Close Excel file from VBScript without being prompted? 昨天在 Excel 打开了 a.iqy 文件,现在每次我尝试打开一个新工作簿时,Excel 都会尝试打开这个文件 - Opened up a .iqy file yesterday in Excel, now every time I try to open a new workbook, Excel tries to open up this file 如何使用JavaScript读取iqy文件结果表 - How to read a iqy file result table with javascript 如何将.iqy 文件加载到 excel 作为数据源 - How to load .iqy file into excel as datasource a.iqy 文件有哪些选项? - What are the options for a .iqy file? 如何编辑 BigQuery Connector for Excel .iqy 文件以在其中包含 SQL 语句,而不是依赖于 Excel 单元格的输入? - How do I edit the BigQuery Connector for Excel .iqy file to have the SQL statement already in it instead of relying on input from an Excel cell? IE 11 和 Office 365 - 让 Excel 打开而不是被提示 - IE 11 & Office 365 - getting Excel to open instead of being prompted 如何在不锁定的情况下打开Excel文件? - How can I open an Excel file without locking it? 如何在没有提示的情况下使用com4j API保存Excel工作簿 - How to save excel workbook using com4j API without being prompted
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM