PDA

View Full Version : Open EXPLORER to specific folder



LanceMcHatton
2004-09-27, 11:30 PM
I have a button that will open windows explorer with this code:

^C^CEXPLORER

I want it to go to a specific folder, for example:

C:\TEMP

Does anyone know how to do that?


Thanks,
Lance

Mike.Perry
2004-09-27, 11:34 PM
Hi

Check out the following Submission # EX001036 on the AUGI Exchange Page -

AUGI Exchange Search Page (http://www.augi.com/exchange/search.asp?page=415)

Have a good one, Mike

Ed Jobe
2004-09-28, 02:43 PM
If you just want to customize a shortcut, you can find help here (http://support.microsoft.com/default.aspx?scid=kb;en-us;307856).

Ed Jobe
2004-09-28, 10:03 PM
Mike, You inspired me. I didn't realize that I do that frequently...but I thought that should be easily accessible. So I put it on the default rt+clk menu. Here is the vba code.


'Put this code in a public module and create
'a lisp wrapper for it called "ExploreDrawing"
Public Sub ExploreDrawing()
'Opens an Explorer window to the folder of the current drawing.
On Error GoTo Err_Control
Shell "Explorer /e,""" & ThisDrawing.Path & "", vbNormalFocus

Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
'Add your Case selections here
'Case Is = 1000
'Handle error
'Err.Clear
'Resume Exit_Here
Case Else
MsgBox Err.Number & ", " & Err.Description, , "ExploreDrawing"
Err.Clear
Resume Exit_Here
End Select
End Sub

'Add this code to an event class module that gets initialized at startup.

Private mItem As AcadPopupMenuItem
Private mSep As AcadPopupMenuItem

Private Sub Doc_BeginShortcutMenuDefault(ShortcutMenu As IAcadPopupMenu)
Set mItem = ShortcutMenu.AddMenuItem(2, "Explore this drawing's folder", Chr(3) & Chr(3) & "ExploreDrawing" & vbCr)
Set mSep = ShortcutMenu.AddSeparator(3)
End Sub

Private Sub Doc_EndShortcutMenu(ShortcutMenu As IAcadPopupMenu)
If ShortcutMenu.Name = "Context menu for default mode" Then
If Not mItem Is Nothing Then mItem.Delete
If Not mSep Is Nothing Then mSep.Delete
End If
End Sub

LanceMcHatton
2004-09-29, 08:38 PM
Ok, I'm getting closer. Here's the code I have so far:


(defun c:GCWOpenCADSF ()
(startapp "Explorer" "L:/GCW-menus")
(princ)
)


It keeps saying "The path 'L:/GCW-menus' does not exist or is not a directory."

However, it will work if I change the path like this:

(defun c:GCWOpenCADSF ()
(startapp "Explorer" "L:")
(princ)
)

It goes to the L: drive just fine but nothing beyond that. I know the folder exists, I even copy/pasted it from windows explorer. I tried , /, and but none of them work.

Mike.Perry
2004-09-29, 08:52 PM
Hi

Try using double back slashes ie

L:\\GCW-menus

Have a good one, Mike

Glenn Pope
2004-09-29, 08:54 PM
Try using \\ in the address.

Glenn Pope
2004-09-29, 08:55 PM
You beat me to it Mike :wink:

LanceMcHatton
2004-09-29, 09:05 PM
I went ahead and took care of the problem by using the "BROWSER" command instead.


^C^C_browser L:/GCW-menus/CADSettingFiles

But if anyone has a solution to the original question, I'd be happy to see it.

Thanks,
Lance

LanceMcHatton
2004-09-29, 09:07 PM
I did try the double slashes. I mentioned it in a previous post but it didn't come thru the Forum well. It just showed up as commas.

Ed Jobe
2004-09-29, 09:23 PM
Did you try using the /e or /select switches as shown in the msdn doc I gave you?
Explorer /e,path
Explorer /select,path

I also provided another solution, although in vba. It uses the shell command which allows you to specify the window type to open, i.e. maximized, minimized.

Mike.Perry
2004-09-30, 11:28 AM
I did try the double slashes. I mentioned it in a previous post but it didn't come thru the Forum well. It just showed up as commas.Hi

Now that I got AutoCAD in-front on me I've been able to carry out a little test -

Using double back slashes \\ within the path should definitely work ie


(defun c:GCWOpenCADSF ()
(startapp "Explorer" "L:\\GCW-menus")
(princ)
)
Obviously for the above to work correctly (without error) the Directory/Folder "GCW-menus" must first exist on the "L" Drive.

Have a good one, Mike

Ed Jobe
2004-09-30, 02:47 PM
I found a bug with the AddMenuItem method. When you add an item to the default menu, it messes up the 'repeat last command' function. The function still works, but displays as "Repeat %S". The var doesn't get updated. Since what I need to do is not dynamic, my workaroung was to just edit the shortcut menu at startup. Here is a function to do that.


Sub ModifyDefaultShortcutMenu()

Dim mItem As AcadPopupMenuItem
Dim mSep As AcadPopupMenuItem
Dim pm As AcadPopupMenu

For Each pm In AcadApplication.MenuGroups("acad").Menus
If pm.Name = "Context menu for default mode" Then
Set mItem = pm.AddMenuItem(2, "Explore this drawing's folder", Chr(3) & Chr(3) & "ExploreDrawing" & vbCr)
Set mSep = pm.AddSeparator(3)
End If
Next
End Sub

richard.binning
2004-09-30, 09:15 PM
Hi

Now that I got AutoCAD in-front on me I've been able to carry out a little test -

Using double back slashes // within the path should definitely work ie


(defun c:GCWOpenCADSF ()
(startapp "Explorer" "L:\\GCW-menus")
(princ)
)
Obviously for the above to work correctly (without error) the Directory/Folder "GCW-menus" must first exist on the "L" Drive.

Have a good one, Mike
Here is an alternate method as well:



(defun c:custfiles2 () ;localrootprefix
(command "shell"
(strcat "explorer \"" (getvar "localrootprefix") "\"")
)
(princ)
)