Jump to content
Macro Express Forums

Get Current Folder From Explorer


mgrantom

Recommended Posts

I'm trying to write a macro to process files in a sub-folder. I want the macro to startup and get the list of files in the current folder, store the filename in a variable, the current folder name in a variable, the name of the parent folder in another variable. I will then use that information in another program where each variable will be pasted into various fields.

 

I know that I can have ME allow me to browse for a folder to start with using the Set String from folder with prompt but this is too cumbersome. I want to either use Windows Explorer (launched to a particular folder) and then allow the user to browse to the correct folder. I cannot figure out how to pass the folder that has been browsed into to ME. I could also use a windows file | open dialog box from within Wordperfect (ver 12) which would already be in the correct folder. How can I pass the current folder in either Explorer or WP to the macro? Thanks in advance.

Link to comment
Share on other sites

I’m sure there’s a more elegant way using some scripting but one sleazy solution might be to enable the full path in Windows Explorer. That is have Windows Explorer display the full path in the address bar. Personally I don’t understand why this isn’t done by default but that’s just me. Anyway you could have ME grab the path from the address bar and use that for your basis.

 

As for WP I don’t know if I uses the standard Windows ‘open’ dialog box but if it does you could employ a trick I’ve used in the past. I once wrote a macro that disposed of a PDF file based on user info. It worked fine if they browsed to it but that was a pain and often they already had it open. So I had ME sense if Acrobat had a file open and if it did I had ME jump thru the hoops of doing a “File Saveas” to get the dialog box up. Once the dialog box was up I could grab the path and file name using Windows controls.

 

With Word you can get this from the file properties but in Acrobat there was no such way. WP might have something similar so you might check there. Also many applications will cache their current working directory in the registry someplace. Find it and you could set your dir from it.

Link to comment
Share on other sites

Thanks for the ideas, coincidentally, I believe I saw your macro when I was looking around for answers. I didn't fully understand what I was looking at but I did book mark it since it looked like it had some interesting capabilities. Your explanation might help me and I'll look at it again.

 

I'm experimenting with the get control command. I thought I had it, but it does not work when I change the directory from the default setting. This is what I have tried:

 

<LAUNCHDEL2:0:00C:\WINDOWS\explorer.exe<PARAM>\\newintel\g\wordperf\cases><PAUSE2:000Top,00LeftSelect a folderT><GETCONTROL2P:01:EXPLORER.EXE:CabinetWClass\\newintel\c\wordperf005:1WorkerW1ReBarWindow321ComboBoxEx322ComboBox1Edit><VARGETCONT:1:1><TBOX4:T:4:CenterCenter000278000200:000:Windows ExplorerExplorer contains %T1%><DIS:<PAUSE2:000Top,00LeftpausedT><REM2:Launch Notepad><LAUNCHYES3:0:0012notepad<LAUNCH:notepad.exe><REP3:07:000005:000001:0002:0:01:%T1%><TEXTTYPE:%T2%<ENTER>><ENDREP>

Link to comment
Share on other sites

I don’t have time to play with your code and don’t have much time in general today but I thought I would toss something out here. Beware of a little problem ME has with controls. It caches control handles so often you can run into problem with windows with same names and similar index structures. A while back I had a big long post regarding the matter and at the end I posted a fix. I don’t remember what it was now off the top of my head but if you dig thru my old posts you will find it. This may solve your problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...