Info

End Function

Private Function TrimNull(ByVal strltem As String) As String Dim intPos As Integer intPos = InStr(strItem, vbNullChar)

If intPos > 0 Then

TrimNull = Left(strItem, intPos - 1)

Else

TrimNull = strItem End If

End Function

This is the actual program created to use this information:

Function GetFileName(strPath As String) Dim strFilter As String Dim lngFlags As Long strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)") GetFileName = ahtCommonFileOpenSave(InitialDir:=strPath, _ Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _ DialogTitle:="Please select file to import")

End Function

Then create the userform. The following code is attached to the Browse button as shown in Figure 22.9. Note that the function specifies the starting directory.

Private Sub cmdBrowse_Click() txtFile = GetFileName("c:\")

Figure 22.9

Create a custom browse window to return the file path of a user-selected file.This can be used to ensure the user doesn't select the wrong file for import.

Figure 22.9

Create a custom browse window to return the file path of a user-selected file.This can be used to ensure the user doesn't select the wrong file for import.

0 0

Post a comment