Minggu, 16 Juni 2013

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

 


I guess I can lump that kind of thing into another branch of what I call "Paradigm Polution".
I originally coined the term (I am the original Paradigm Police) as more and more sites began scattering links here and there as well as things that look like links that aren't and links that don't look like links; menues here and there and all manner of other "user hostile" creations.
Perhaps this is the "Paradigm Permutation" branch...

REF: Unfortunately, Jacob Nielsen has gone big time and no longer has his web design/complaint site (useit.com) giving usability informatoin... A taste is here:
http://chnm.gmu.edu/digitalhistory/links/cached/chapter4/4_2_useit.htm
Regards, Steve

--- In ExcelVBA@yahoogroups.com, Paul Schreiner <schreiner_paul@...> wrote:
>
> I'm glad to see that you've grasped what I tossed your way.
> Sometimes, it just takes a nudge.
>  
> Now that I know a bit of your background, I may be able to describe stuff as it relates.
> I often switch between UNIX and Windows.. then I have VBScripts that create .BAT files...  yeah.. (\) and (/)...
> I get it right about 1/2 the time on the first try.
>  
> ThisWorkbook and ActiveWorkbook becomes REAL significant when you decide you want your code in a kind of "template" file that then opens working files that change periodically.
>  
> good luck,
>  
> Paul
> -----------------------------------------
> “Do all the good you can,
> By all the means you can,
> In all the ways you can,
> In all the places you can,
> At all the times you can,
> To all the people you can,
> As long as ever you can.” - John Wesley
> -----------------------------------------
>
>
> >________________________________
> >From: noskosteve <noskosteve@...>
> >To: ExcelVBA@yahoogroups.com
> >Sent: Thursday, June 13, 2013 7:38 PM
> >Subject: [ExcelVBA] Re: Specifying the Directory in which the Workbook resides?
> >
> > 
> >
> >
> >Thanks, Paul.
> >Somehow I didn't think to ping the Object Browser, nor VBA's Help with "Path". There's a lot more there.
> >Knowledge is like radioactive elements. Though I've done (and taught) a bunch of DOS stuff, when you can't remember if the path separator is / or \ you know that you have exceeded some knowledge half-life.
> >
> >Nice to know that exists, but in this situation, there should only be one workbook open. However, thinking about this issue, it is the workbook with the code that is needed. I will place (or instruct others to place) the code-laden workbook and the other SW in the same directory. Then, even if another workbook should happen to be active, the data will transfer correctly.
> >
> >I will actually be doing some Serial I/O with Excel and feeding converted data to the other program which has the option of accepting file input instead of COM port input. I would use the COM port input of the other software, but the hardware I have that provides the serial data provides an incomparable format. Excel will simply be a format converter for this step in the development. A pile driver for a thumb tack, but it also allows some additional data analysis not in the other SW.
> >Also, this is a way of testing the concept before considering other solutions.
> >When the only tool you have is a hammer, every problem looks like a nail.
> >
> >Excel VBA is a complete progtamming development 'environment'...with a gui to boot.
> >
> >Regards, Steve N.
> >
> >--- In mailto:ExcelVBA%40yahoogroups.com, Paul Schreiner <schreiner_paul@> wrote:
> >>
> >> When you say: "Dir-Where-The-Workbook-Is-Located"
> >> does "workbook" refer to the Active Workbook
> >> or the workbook that contains the code that's running?
> >>  
> >> If it's the workbook that has the code that's running, then:
> >>  
> >> ThisLoc = Thisworkbook.Path
> >>  
> >> will give you the folder where the workbook (that contains the code) is located.
> >>  
> >> If you're wanting the of the active workbook, then:
> >> Activeworkbook.Path
> >>  
> >> should give it to you.
> >>
> >> Paul
> >> -----------------------------------------
> >> “Do all the good you can,
> >> By all the means you can,
> >> In all the ways you can,
> >> In all the places you can,
> >> At all the times you can,
> >> To all the people you can,
> >> As long as ever you can.” - John Wesley
> >> -----------------------------------------
> >>
> >>
> >> >________________________________
> >> >From: noskosteve <noskosteve@>
> >> >To: mailto:ExcelVBA%40yahoogroups.com
> >> >Sent: Thursday, June 13, 2013 2:48 AM
> >> >Subject: [ExcelVBA] Specifying the Directory in which the Workbook resides?
> >> >
> >> > 
> >> >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
> >> >
> >> >
> >> >
> >>
> >> [Non-text portions of this message have been removed]
> >>
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)
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