View Full Version : Sleeper: Code for browse button
v_gyku
09-05-2005, 09:48 PM
My GUI contains a label PLease select workbook.. To select Workbook click on browse button...(After clicking the browse button user should be able to select excel workbook from the window..it will be a normal browse window like in our computer.)
Next label is select worksheet u wish to eamil from the following...
NOw all the sheets from the above selected workbook should be displayed in this textbox.I have made textbox size large enough so that 5, 6 sheet names can be displayed one below the other.
royUK
09-05-2005, 10:06 PM
Try this
' Module : Module1
' DateTime : 06/09/2005 06:04
' Author : royUK
' Website : www.excel-it.com (http://www.excel-it.com/)
' Purpose : Display open File Dialog
Option Explicit
Sub OpenFile()
Application.GetOpenFilename
End Sub
v_gyku
09-05-2005, 10:26 PM
I didn't got any examples i wanted...
v_gyku
09-05-2005, 11:22 PM
I have this code to select access datbase ..
Can u modify it to select excel workbook???
Private Sub CmdBrowse_Click()
Dim i As Integer
Dim mypath As String
Dim multiselect As Boolean
If IsAppOpen("Access", "Application") Then
MsgBox "Please close all Access applications"
Exit Sub
End If
'Set the multiselect files value - only one file can be chosen
multiselect = True
filetype = "Access database"
FileFilter = "Access databases" & Chr(0) & "*.mdb*" & Chr(0)
fileArray = GetFilesBrowse(objBrowseButton:=CmdBrowse, _
objFileList:=txtFileLocation, _
strFileType:=filetype, _
strFileFilter:=FileFilter)
List1.Enabled = True
Dim strFormName As Access.Form
Dim file As String
If txtFileLocation.Text = "" Then
Exit Sub
End If
file = Right(txtFileLocation.Text, Len(txtFileLocation.Text) - InStrRev(txtFileLocation.Text, "\"))
ShowAccessforms myDatabase:=filenames, myList:=List1, myFileLocation:=txtFileLocation
End Sub
royUK
09-06-2005, 01:01 AM
The best control for this is ListBox not a TextBox
'---------------------------------------------------------------------------------------
' Module : UserForm1
' DateTime : 06/09/2005 09:00
' Author : royUK
' Web site : www.excel-it.com
' Purpose : list worksheets in ListBox
'---------------------------------------------------------------------------------------
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With Me.ListBox1
.AddItem ws.Name
End With
Next ws
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.