Rabu, 12 Juni 2013

[ExcelVBA] Re: Specifying the Directory in which the Workbook resides?

 


Never mind... sigh.
Reworded my Search and found ThisWorkbook.Path

Thanks for the rapid help, Steve......

--- In ExcelVBA@yahoogroups.com, "noskosteve" <noskosteve@...> wrote:
>
> Greetings yon Gurus,
>
> I already have VBA code that reads and writes files just fine, but that code uses the usual explorer-like File dialog that allows you to navigate around to find the desired directory to read from or write to.
>
> I want to write VBA code that sends data to another program that can accept input from files. This allows me to do some conversions in Excel that is required for the other software.
> I suppose this can be called File handshaking (as opposed to software or hardware handshaking). There is a Flag File and a Data File. The mere presence or absence of the Flag file lets VBA know when to write to the Data file.
>
> I want to have the communication transparent by having the Workbook, the other software and the two communication files in the same unspecified directory. Therefore the full path is unknown.
>
> So I need a "Dir-Where-The-Workbook-Is-Located" Function.
>
> I see how the DIR function works to test the existence of a file, but at some point after testing my code, the directory changed from the one that the Workbook was in to the Documents directory.
>
> DIR(NoPathFilename) looks in the 'current' directory.
>
> I see both the CHDIR (change DIR) and the CURDIR (Current DIR) functions, but CURDIR is the currently _selected_ DIR, not the Workbook's directory. Other related functions in Excel's (Directories and Files Keyword Summary) Help don't appear to do this and Google only got me to the above two mentioned functions.
>
> Any pointers on how to specify the workbook's DIRectory, so the interface works no matter where the workbook (and other SW) is
> co-located?
>
> Regards, Steve
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar