Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system modal

Status
Not open for further replies.

bntwillis

Technical User
Joined
Jan 17, 2004
Messages
5
Location
US
Hello,

I am a new developer who has been asked to support some VBA code written to automate document generation through a case tool, and I have a question.

When generating the document the user may have the option to pick a config file if more than one config file is associated with the information to be generated. A vb form was created to handle this. The form gets launched if more than one config file is available. This all works correctly. The only problem is that the focus is set on the application launching the document generation, not on the vb form that has been launched. This vb form is associated with Word.
Here is the code that launches the form:

If dlgConfigDialog.ListCount > 1 Then
dlgConfigDialog.Show vbModal
End If
Set dlgConfigDialog = Nothing

I was confused at first because the form is set to vbModal in the code and I thought that this would set the focus to the form. Well a co-worker explained to me that this setting was at the application level and not at the system level. He gave me some code that he thought would fix it.

Here is the code:

Private Declare Function FindWindow Lib "USER32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SetSysModalWindow Lib "User" (ByVal hWnd As Integer) As Integer
Dim hWndForm As Long

hWndForm = FindWindow("ThunderDFrame", oForm.Caption)
retval% = SetSysModalWindow(hWndForm)

But every time I try and compile this I get the following error:
Compile Error:
Only comments may appear after End Sub, End Function, or End Property

Like I said I am a new developer, less than 2 months experience, and I would appreciate any direction that can be offered.
 
Have you tried this ?
If dlgConfigDialog.ListCount > 1 Then
dlgConfigDialog.Show vbModal
Application.ActivateMicrosoftApp xlMicrosoftWord
End If


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top