在VBA中使用记录集excel [英] Using recordset in VBA excel
问题描述
打开并从第12个文件中获取信息。
您好,
您收到任何错误吗?你是什么意思VBA死了? Excel会崩溃吗?
根据您的描述,我建议您专门连接这些文件以确认连接是否适用于每个文件,然后将它们合并到一个循环中。
从您的连接字符串,您是否连接到.xlsb文件?
对于不同的文件扩展名,连接字符串中的extendeed属性会有所不同。
xlsx文件:
提供商 = Microsoft.ACE.OLEDB.12.0; 数据源 = c:\ myFolder \ myExcelfile.xlsx;
扩展属性 = " Excel 12.0 Xml; HDR = YES";
将数据作为文本处理
提供商 = Microsoft.ACE.OLEDB.12.0; 数据源 = c:\ myFolder \\ \\ myExcelfile.xlsx;
扩展属性 = " Excel 12.0 Xml; HDR = YES; IMEX = 1";
Xlsb文件:
提供商 = Microsoft.ACE.OLEDB.12.0;
数据源 = c:\\ \\ myFolder \ myBinaryExcelfile.xlsb;
扩展属性 = " Excel 12.0; HDR = 是" ;;
Xlsm文件:
提供商 = Microsoft.ACE.OLEDB.12.0; 数据源 = c:\ myFolder \ myExcelfile.xlsm;
扩展属性 = " Excel 12.0宏; HDR = 是" ;;
问候,
Celeste
Hello,
Do you get any error? What do you mean VBA dies? Does Excel crash ?
According to your description, i would suggest you connect to these file sperately to confirm the connection works for every file, then combine them in a loop.
From your connection string, do you connected to .xlsb files?
For different file extension, the extendeed properties would be different in the connection string.
xlsx file:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcelfile.xlsx;
Extended Properties="Excel 12.0 Xml;HDR=YES";Treating data as text
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcelfile.xlsx;
Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";Xlsb files:
Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\myFolder\myBinaryExcelfile.xlsb;
Extended Properties="Excel 12.0;HDR=YES";Xlsm file:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcelfile.xlsm;
Extended Properties="Excel 12.0 Macro;HDR=YES";Regards,
Celeste
这篇关于在VBA中使用记录集excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!