Is there some way to list all the forms that are present in an application. I cannot use the forms collection since it only lists the loaded forms, I want to list ALL the forms that are part of an application
You can get the list from the project file .vbp. Probably not the solution you were looking for but here it is.
Dim strTest As String
Open "C:\SomeDir\ProjectFile.vbp" For Input As #1
Do While Not EOF(#1)
Input #1, strTest
If Left(strTest, 5) = "Form=" Then
debug.print Mid(strTest,6)
End If
Loop
Close #1
Actually, aside from the somewhat slow line input method, I believe it is the prefered method for VB. On the other hand, the question "looks like" an MS Access question. If THAT is the case, it is definitly not the approach, but iteration through the AllForms Collection could be used (Ms. A. 2K) or through the Forms DOCUMENTS fr earliser versions. Help is helpful for either / both (in Ms. A.)
It is at least CLOSE, so check the ever helpful "HELP" ... it is generally better at the exact syntax for simple operations and it is certainly faster to respond than any web site.
Don't think you need an API call - just add the form to the Forms Collection and it will be loaded (but not shown)
[tt]
Dim strForm As String
strForm = "Form4"
Forms.Add strForm
[/tt]
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
Try this: add this code to a new project along with 2 forms Form1 and Form2 add a command button to Form1.
Public colForms As New Collection
Public Sub LoadForm(strFormName As String)
Dim frm As Form
Set frm = colForms(strFormName)
frm.Show
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim strForm As String
strForm = "Form2"
colForms.Add Form2, "Form2"
LoadForm (strForm)
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.