本文介绍了将excel连接字符串default dir更改为当前工作簿目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DefaultDir=C:\SOMEDIRECTORY;Driver={Microsoft Text Driver (*.txt; *.csv)};DriverId=27;FIL=text;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;





以上是用于获取数据透视表中使用的外部数据的连接字符串。



在VB中我将目录设置为ActiveWorkbook.Path没有问题,这样当我查询(来自VB)或写入文件时,它们会被找到并放在正确的位置。但是,当我对我的过滤数据进行查询时,我找不到如何将DefaultDir(上面的SOMEDIRETORY)更改为工作簿所在的任何目录。看起来应该很简单。我愿意使用连接文件,但似乎仍然存在相同的问题。它真的搞砸了工作,因为只要我把应用程序放在另一台计算机上,它就找不到数据了!



我尝试过:



在连接字符串中使用ActiveWorkbook.Path(无法识别)。

拿出DefaultDir - 它只需放回Excel的默认目录。



Above is the connection string used for Excel to get external data that is used in a pivot table.

In VB I have no trouble setting the directory to ActiveWorkbook.Path so that when I do queries (from VB) or write files, they are found and put in the right place. However when I do the query on my filtered data for the pivot, I cannot find how to have the DefaultDir ("SOMEDIRETORY" above) be changed to whatever directory where the workbook is located. It seems like it should be simple. I'm willing to use a connection file, but it seems like the same problem would still exist. It really mucks up the works because as soon as I put the application on another computer, it can't find the data!

What I have tried:

Using ActiveWorkbook.Path in the connection string (doesn't recognize it).
Took out the DefaultDir - it just puts back the default dir for Excel.

推荐答案


这篇关于将excel连接字符串default dir更改为当前工作簿目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:06