Consulting

Results 1 to 5 of 5

Thread: Sleeper: Code for browse button

  1. #1
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location

    Sleeper: Code for browse button

    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.

  2. #2
    Try this


    ' Module : Module1
    ' DateTime : 06/09/2005 06:04
    ' Author : royUK
    ' Website : www.excel-it.com
    ' Purpose : Display open File Dialog
    
    Option Explicit
     
    Sub OpenFile()
    Application.GetOpenFilename
    End Sub
    Hope that helps.
    Get the free Excel based Toolbar or click here for free examples & Excel Consultancy

    RoyUK

  3. #3
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location
    I didn't got any examples i wanted...

  4. #4
    VBAX Regular
    Joined
    Sep 2005
    Posts
    78
    Location
    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

  5. #5
    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
    Hope that helps.
    Get the free Excel based Toolbar or click here for free examples & Excel Consultancy

    RoyUK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •