1,080,548 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by Bile which have been Voted Up

-->>I hope You all drove Me to where I wanted Guys,thats sure AndereRet for what You understood...
-->>@ TnTinMN : This statement
"Are you trying to tell us that you do not understand how to use the CommonDialog to retrieve the selected file?"
-->>Helped Me to Open My Eyes a bit wider,I knew that there is something in Your Code and so I took ...
-->>a time to Study it then Modify it and hence got Your Point!!!...
-->>I was a little bit blind to see but all I needed was in Your Code let Me show some modification...
-->>thought not exactly total modification but based on My demands here it goes:
-->>I have a Form (Files) with a Command Button (Browse) and a CommonDialog (Folder):..
-->>I have a Module with TnTinMN's Code a little bit modified to this in the Module:

Option Explicit
Private Declare Function AssocQueryString Lib "shlwapi.dll" Alias "AssocQueryStringA" _
    (ByVal flags As AssocF, _
    ByVal str As AssocStr, _
    ByVal pszAssoc As String, _
    ByVal pszExtra As String, _
    ByVal pszOut As String, _
    ByRef pcchOut As Long) As Long
    Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hWnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Integer) As Long
    Enum AssocF
    Init_NoRemapCLSID = &H1
    Init_ByExeName = &H2
    Open_ByExeName = &H2
    Init_DefaultToStar = &H4
    Init_DefaultToFolder = &H8
    NoUserSettings = &H10
    notruncate = &H20
    Verify = &H40
    RemapRunDll = &H80
    NoFixUps = &H100
    IgnoreBaseClass = &H200
    End Enum
    Enum AssocStr
    Command = 1
    Executable
    FriendlyDocName
    FriendlyAppName
    NoOpen
    ShellNewValue
    DDECommand
    DDEIfExec
    DDEApplication
    DDETopic
    INFOTIP
    QUICKTIP
    TILEINFO
    CONTENTTYPE
    DEFAULTICON
    SHELLEXTENSION
    DROPTARGET
    DELEGATEEXECUTE
    SUPPORTED_URI_PROTOCOLS
    Max
    End Enum
    Private Const S_OK As Long = &H0
    Private Const MAX_PATH As Long = 260
    Public Function GetAsscociatedExe(ByVal Docment_Type As String) As String

    GetAsscociatedExe = String$(MAX_PATH, " ")

    Dim pcchOut As Long
    pcchOut = MAX_PATH

    Dim Result As Long

    Result = AssocQueryString(AssocF.Verify, AssocStr.Executable, Docment_Type, "open", GetAsscociatedExe, pcchOut)
    If Result <> 0 Then
    GetAsscociatedExe = vbNullString
    Else
    GetAsscociatedExe = Left$(GetAsscociatedExe, pcchOut - 1)
    End If
    End Function

    Public Sub Open_File(File_Name As String)

     Dim File_Extension As String
     Dim Executable_Program As String
     Dim Start_Program As Long

     File_Extension = ".MP3"
     Executable_Program = GetAsscociatedExe(File_Extension) 

    '' I TOOK METHOD 2 : ShellExecute
     If Executable_Program <> vbNullString Then

     Start_Program = ShellExecute(0, "open", "" & File_Name & "", vbNullString, vbNullString, vbNormalFocus)
     Else
     MsgBox "Sorry  Can't Find a Program to Open " & File_Extension & " File Extension.", vbOKOnly + vbInformation, "You need a Program to Open Your File"
     End If
    End Sub

-->>And this for CommonDialog to Showup and some filtering criteria and so forth...

Public Sub User_Folder(Users As CommonDialog)
'******************************************************************'
'*       COMMON PROCEDURE TO ACCESS USER FOLDER IN A SYSTEM       *'
'******************************************************************'


With Users
            '**************************************'
            '* SETS THE DIALOG TITLE TO OPEN FILE *'
            '**************************************'
        .DialogTitle = USER_NAME & "'S SPGPAC - File DOCUMENTS."
            '***************************************'
            '* SETS THE DIALOG'S INITIAL DIRECTORY *'
            '***************************************'
        .InitDir = GetAppPath() & "SPGPAC - File User Files\" & USER_NAME & "\"
            '**************************'
            '* SETS THE FILE LIST BOX *'
            '**************************'
        .Filter = "(*.bmp; *.jpg; *. gif; *.pcx; *.mp3;*.pcx;)| *.bmp; *.jpg; *.gif; *.pcx; *.mp3;*.pcx;|" & _
                  "(*.wma; *.wav; *.mpg; *.avi; *.VOB;*.png;)|*.wma; *.wav; *.mpg; *.avi; *.VOB;*.png;|" & _
                  "(*.mdb; *.txt; *.doc; *.xlsx; *.pptx;*.psd;)|*.mdb; *.txt; *.doc; *.xlsx; *.pptx;*.psd;|" & _
                  "(*.pub; *.pdf; *.chm; *.docx; *.php;)|*.pub; *.pdf; *.chm; *.docx; *.php;|" & _
                  "(*.html; *.bmp; *.jpg; *.gif; *.dat;)|*.html; *.bmp; *.jpg; *.gif; *.dat;|" & _
                  "(*.All files)|*.*|"
            '******************************************'
            '* SET THE DEFAULT FILES TYPE TO ALL FIES *'
            '******************************************'
        .FilterIndex = 28
            '*******************************************************'
            '* SETS THE FLAGS - FILE MUST EXIST AND HIDE READ ONLY *'
            '*******************************************************'
        .flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
            '*******************************************************************'
            '* SET DIALOG BOX SO AN ERROR OCCURS IF THE DIALOGBOX IS CANCELLED *'
            '*******************************************************************'
        .CancelError = True
            '************************************************'
            '* ENABLES ERROR HANDLING TO CATCH CANCEL ERROR *'
            '************************************************'
            On Error Resume Next
        '**************************'
        '* DISPLAY THE DIALOG BOX *'
        '**************************'
        .ShowOpen

        If Err Then
            '**********************************************'
            '* THIS CODE RUNS IF THE DIALOG WAS CANCELLED *'
            '**********************************************'
            MsgBox "Browsing Dialog Cancelled", vbOKOnly + vbInformation, "User Documents Cancelled"
            Exit Sub
        End If

'***************************'
'* DISPLAYS A MESSAGE BOX. *'
'***************************'
Open_File .FileTitle

End With

End Sub

-->>NOTE LINE 57: Calls the Function Open_File() in this Module and Pass the File Name of the...
-->>CommonDialog Users and so execution goes there...
-->>Now back to the form Files in Command Button Browse I have this code:

User_Folder Folder

-->>Only Calling the Sub User_Folder and everything was NICE and as I wanted...
-->>But @ TnTinMN why Should I initialize File_Extension as I did or what You did in Your code...
-->>exten = ".docx" though I used File_Extension = ".MP3" to only One Type of file Extension...
-->>while I have Lots of files to be Open as Per Filtering Criteria?...
-->>By omiting the Line an Error Occurs so is there a way I can Just state that all type of file...
-->>Extension is equal ti exten or File_Extension (in My Line)?
-->>Although all files get opened appart of what Extension has been Initialized...
-->>@ AndreRet I hope as well You will now be able to Open Your Word Files with TnTinMN Code...
-->>Thaks Once again AndreRet and TnTinMN...

Bile
Junior Poster in Training
90 posts since Dec 2010
Reputation Points: 20
Solved Threads: 3
Skill Endorsements: 0

-->>Asumming that you have a command button named Sum...
-->>Then under its event click,just try to code the following...

Private Sub Sum_Click()
txtBox2.Text = Val(txtBox2.Text) + Val(txtBox1.Text)
End Sub

-->>If I did understand the question "I am desgining a userform in ArcMap,..." becouse I dont know what the ArcMap is...
-->>But as far as what is just needed to add the Numbers the above code may help or just give a light...
-->>Thanks.

Bile
Junior Poster in Training
90 posts since Dec 2010
Reputation Points: 20
Solved Threads: 3
Skill Endorsements: 0

-->>Tanx Andre,its clear for me as well...

Bile
Junior Poster in Training
90 posts since Dec 2010
Reputation Points: 20
Solved Threads: 3
Skill Endorsements: 0
Bile
Junior Poster in Training
90 posts since Dec 2010
Reputation Points: 20
Solved Threads: 3
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page generated in 0.0917 seconds using 2.5MB