'This form uses a 3 page multipage control to imitate a wizard
'Page1 lists the type of studies and their associated document types
'Page2 gathers the information common for all documents generated
'Page3 is used to identify approvers for each document. This can be
'omitted or changed once the documents are created.
Option Explicit
Dim ListArray() As String
Dim str_DList As String
Dim str_AList As String
Dim str_Author As String
Dim str_DocType As String
Dim str_Path As String
Dim fs As Variant
Dim int_LcLen As Integer
Dim int_Len As Integer
Dim int_LCnt As Integer
Dim x As Integer
Dim i As Integer
Dim str_Location As String
Private Sub UserForm_Initialize()
'avoid an error by setting focus to first page (index 0) of the multipage
MultiPage1.Value = 0
'get path to the source files
str_Location = ActiveDocument.CustomDocumentProperties("Source Path").Value
If Right(str_Location, 1) <> "\" Then str_Location = str_Location + "\"
'set default approvers (to avoid an error when changing to page2 with no study selected
str_AList = str_Location + "Default.csv"
'populates the first list box with the study types the template supports
Set fs = Application.FileSearch
With fs
.LookIn = str_Location
.SearchSubFolders = False
.FileName = "*.txt"
If .Execute() > 0 Then
lstStudy.Visible = True
For i = 1 To .FoundFiles.Count
int_LcLen = Len(str_Location) + 1 ' may require and adjustment, not sure why
' the list looks cleaner without path or extension
int_Len = Len(fs.FoundFiles(i)) - int_LcLen - 3
lstStudy.AddItem Mid(fs.FoundFiles(i), int_LcLen, int_Len)
Next i
Else
MsgBox "The validation template source files could not be found." + vbNewLine _
+ "Contact the application owner for assistance."
Exit Sub
End If
End With
End Sub
|