View Full Version : Browse Button
caddog71
2007-06-25, 07:02 PM
I am make a form that will load a drawing file from a specific location on our server based on certain criteria entered. I want to add a "Browse" button at the bottom of my form to enable the user to search for the file they need and open using that method. I know that I am supposed to use Common Dialog Controls. But I'm not to sure on who to get it to work. Can you help me find an "How to article" on this process? Thank you for the help. By the way I'm new to VBA so please keep that in mind with your responses.
Much Thanks
Ed Jobe
2007-06-25, 09:32 PM
Is this project VB or VBA? The common dialog congrols are only licensed for VB.
Try a google search for the "Showopen" method.
Ex: http://www.eng-tips.com/viewthread.cfm?qid=100581
Regards Claus
jwanstaett
2007-07-02, 08:36 PM
If you do not mine using the sendcommand fiction you can use the attach file to show the autocad lisp browner it add some function that the window browner dose not have.
It save the value return by the getfiled fiction in the users1 sys var.
Ed Jobe
2007-07-02, 08:42 PM
If you do not mine using the sendcommand fiction you can use the attach file to show the autocad lisp browner it add some function that the window browner dose not have.
It save the value return by the getfiled fiction in the users1 sys var.
John, the spell checker is your friend. ;)
There are better ways to interact with lisp than SendCommand. You can even access acad's file dialog using a Declare stmt and forget lisp.
jwanstaett
2007-07-02, 09:33 PM
John, the spell checker is your friend. ;)
There are better ways to interact with lisp than SendCommand. You can even access acad's file dialog using a Declare stmt and forget lisp.
what is the declare stmt to get to a lisp.
Ed Jobe
2007-07-02, 10:20 PM
what is the declare stmt to get to a lisp.
You misread that. The Declare allows you to not use lisp. It is for a function in one of the acad dll's for the color dialog and the file dialog. You should find a reference to them in this forum. I'm going home now. If you don't find it, I might be able to help tomorrow.
arshiel88
2007-07-03, 04:20 AM
Right click the toolbox of your VBA IDE, and check (or x) Microsoft Common Dialog Control.
Place 1 in your form.
Then Call CommonDialog1.ShowOpen. :) simple.
The file opened is stored in CommonDialog1.Filename.
for the Declare Function on which you call common dialogs without loading the control.
check this (http://www.visualbasic.happycodings.com/Common_Dialogs/code6.html)
Ed Jobe
2007-07-03, 02:04 PM
Right click the toolbox of your VBA IDE, and check (or x) Microsoft Common Dialog Control.
That's what I was referring to in my first post. The ELUA for vba does not allow you to use controls that come with VB, the CDC being one of them.
Ed Jobe
2007-07-03, 02:22 PM
'ACAD color dialog
Public Declare Function acedSetColorDialog Lib "acad.exe" (color As Long, _
ByVal bAllowMetaColor As Boolean, ByVal nCurLayerColor As Long) As Boolean
'Color choice using autocad color selection dialog box
'
Public Function AcadColor(ByVal lngInitClr As Long, ByVal blnMetaColor As Boolean, _
ByVal lngCurClr As Long) As Long
AcadColor = -1
On Error Resume Next
If acedSetColorDialog(lngInitClr, blnMetaColor, lngCurClr) Then
AcadColor = lngInitClr
End If
On Error GoTo 0
End Function
Here are some other methods (http://forums.augi.com/showthread.php?t=37006&highlight=acad+color).
sgroff
2007-07-03, 04:58 PM
I am make a form that will load a drawing file from a specific location on our server based on certain criteria entered. I want to add a "Browse" button at the bottom of my form to enable the user to search for the file they need and open using that method. I know that I am supposed to use Common Dialog Controls. But I'm not to sure on who to get it to work. Can you help me find an "How to article" on this process? Thank you for the help. By the way I'm new to VBA so please keep that in mind with your responses.
Much Thanks
Copy this code to your routine under ThisDrawing
Sub BROWSE()
Dim FName As String
FName = BrowseFolder("Select a folder", "C:\")
If FName = "" Then
MsgBox "You didn't select a folder"
End If
End Sub
Create a module(if you don't already have one) and copy this code under there.
*Dont include "option explicit" if its already in the module*
Option Explicit
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260
Function BrowseFolder(Optional Caption As String, _
Optional InitialFolder As String) As String
Dim SH As Shell32.Shell
Dim F As Shell32.Folder
Set SH = New Shell32.Shell
Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, _
InitialFolder)
If Not F Is Nothing Then
BrowseFolder = F.Items.Item.Path
End If
End Function
Then on your form, create a button that, when clicked, runs the sub "BROWSE"
Ed Jobe
2007-07-03, 08:34 PM
Oops that's for the Color Dialog. There was a similar function for the file dialoag, but I can't find it. Check out this thread (http://forums.augi.com/showthread.php?t=35457&highlight=filedialogs) to use the windows api.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.