Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Modeless UserForm

I sure hope someone can help me with this one. I have tried everything I
know of (which isn't all that much). I have an excel application that
basically creates a series of multi-pages on a userform based on a directory
hierarchy that it is pointed to. On the multi-pages are buttons for each
file that exists in the folder that the specific multi-page represents. What
I have created is just a simple way to access our companys in-house software
that exists on our server. To do this I had to use what I believe is called
"design mode" so that the application can create the buttons and add the code
for the buttons to the code module. This all works fine, except that it has
become apparent that this userform must be modeless so that it can be left
open. The code I use to call the form is:

VBA.UserForms.Add(TempForm.Name).Show vbModeless

If I leave off the 'vbModeless' portion everything works fine (except that
the form is modal). With the 'vbModeless' included, the userform is shown
for about 1/2 a second and closes and all remaining code executes.

Can anyone explain what is going on here? I can, of course, post additional
code if necessary.

Thanks

Brandt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Modeless UserForm

When your form is modal, the calling routine stops and waits until the
userform is closed and returns execution to it. When the form is modeless,
the procedure shows the form, then continues on its merry way.

What works best for a modeless form is to have one procedure that does
everything up to the showing of the form, then ends, and have another
procedure start when the user form is dismissed (i.e., called by the Close
button code).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
I sure hope someone can help me with this one. I have tried everything I
know of (which isn't all that much). I have an excel application that
basically creates a series of multi-pages on a userform based on a
directory
hierarchy that it is pointed to. On the multi-pages are buttons for each
file that exists in the folder that the specific multi-page represents.
What
I have created is just a simple way to access our company's in-house
software
that exists on our server. To do this I had to use what I believe is
called
"design mode" so that the application can create the buttons and add the
code
for the buttons to the code module. This all works fine, except that it
has
become apparent that this userform must be modeless so that it can be left
open. The code I use to call the form is:

VBA.UserForms.Add(TempForm.Name).Show vbModeless

If I leave off the 'vbModeless' portion everything works fine (except that
the form is modal). With the 'vbModeless' included, the userform is shown
for about 1/2 a second and closes and all remaining code executes.

Can anyone explain what is going on here? I can, of course, post
additional
code if necessary.

Thanks

Brandt



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Modeless UserForm

Jon,

Thanks for your reply. That is exactly what I have (see code below). I've
used modeless userforms successfully in the past, but I can't get it to work
in this case.

Here is the code that auto runs when the application is opened. Everything
after this subroutine is code written as the form is created and should
require user imput to execute.

'----------------------------------------------------------------
Sub OpenFiles()

Dim SubDirectory As String
Dim UserChoice As Variant
Dim FolderArray As Variant
Dim SubFolderArray As Variant
Dim NumOpenApps As Integer
Dim i As Integer
Dim UserDirTest As Integer
Dim ctl As Control

Directory = Sheets("Sheet1").Range("DirDefault").value
UserDirectory = Sheets("Sheet1").Range("DirUser").value

If NumOpenWBs() = 1 Then
Application.Visible = False
Else
ActiveWindow.WindowState = xlMinimized 'application.WindowState =
xlMinimized
End If


Set TempForm = ThisWorkbook.VBProject.VBComponents("UserForm1")

Call Clearform

' Hide VBE window to prevent screen flashing
Application.VBE.MainWindow.Visible = False

FolderArray = GetDirNames(Directory & "\", UserDirectory) 'See mod2 _
UserDirectory Does Not take a "\" Because it is Essentially a Subfolder


'Add Main MultiPage
Call AddMPage(FolderArray, MainMPageTop, MainMPageLeft, MainMPageHeight,
MainMPageWidth)

For i = LBound(FolderArray) To UBound(FolderArray)
SubDirectory = Right(FolderArray(i), Len(FolderArray(i)) -
InStrRev(FolderArray(i), "\")) & "\"
SubFolderArray = GetSubDirNames(CStr(FolderArray(i)) & "\")
Call AddSubMPage(SubFolderArray, SubMPageTop, SubMPageLeft,
SubMPageHeight, SubMPageWidth, i)
Call AddButtons(FolderArray(i), SubFolderArray, i + 2)
Next

Call BuildForm

VBA.UserForms.Add(TempForm.Name).Show 'vbModeless
'DoEvents

End Su
'-------------------------------------------------------------------------------------

Thanks

Brandt



"Jon Peltier" wrote:

When your form is modal, the calling routine stops and waits until the
userform is closed and returns execution to it. When the form is modeless,
the procedure shows the form, then continues on its merry way.

What works best for a modeless form is to have one procedure that does
everything up to the showing of the form, then ends, and have another
procedure start when the user form is dismissed (i.e., called by the Close
button code).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
I sure hope someone can help me with this one. I have tried everything I
know of (which isn't all that much). I have an excel application that
basically creates a series of multi-pages on a userform based on a
directory
hierarchy that it is pointed to. On the multi-pages are buttons for each
file that exists in the folder that the specific multi-page represents.
What
I have created is just a simple way to access our company's in-house
software
that exists on our server. To do this I had to use what I believe is
called
"design mode" so that the application can create the buttons and add the
code
for the buttons to the code module. This all works fine, except that it
has
become apparent that this userform must be modeless so that it can be left
open. The code I use to call the form is:

VBA.UserForms.Add(TempForm.Name).Show vbModeless

If I leave off the 'vbModeless' portion everything works fine (except that
the form is modal). With the 'vbModeless' included, the userform is shown
for about 1/2 a second and closes and all remaining code executes.

Can anyone explain what is going on here? I can, of course, post
additional
code if necessary.

Thanks

Brandt




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Modeless UserForm

You're constructing the userform on the fly? I don't know it that has
anything to do with it, I'm just intrigued.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
Jon,

Thanks for your reply. That is exactly what I have (see code below).
I've
used modeless userforms successfully in the past, but I can't get it to
work
in this case.

Here is the code that auto runs when the application is opened.
Everything
after this subroutine is code written as the form is created and should
require user imput to execute.

'----------------------------------------------------------------
Sub OpenFiles()

Dim SubDirectory As String
Dim UserChoice As Variant
Dim FolderArray As Variant
Dim SubFolderArray As Variant
Dim NumOpenApps As Integer
Dim i As Integer
Dim UserDirTest As Integer
Dim ctl As Control

Directory = Sheets("Sheet1").Range("DirDefault").value
UserDirectory = Sheets("Sheet1").Range("DirUser").value

If NumOpenWBs() = 1 Then
Application.Visible = False
Else
ActiveWindow.WindowState = xlMinimized 'application.WindowState =
xlMinimized
End If


Set TempForm = ThisWorkbook.VBProject.VBComponents("UserForm1")

Call Clearform

' Hide VBE window to prevent screen flashing
Application.VBE.MainWindow.Visible = False

FolderArray = GetDirNames(Directory & "\", UserDirectory) 'See mod2 _
UserDirectory Does Not take a "\" Because it is Essentially a Subfolder


'Add Main MultiPage
Call AddMPage(FolderArray, MainMPageTop, MainMPageLeft, MainMPageHeight,
MainMPageWidth)

For i = LBound(FolderArray) To UBound(FolderArray)
SubDirectory = Right(FolderArray(i), Len(FolderArray(i)) -
InStrRev(FolderArray(i), "\")) & "\"
SubFolderArray = GetSubDirNames(CStr(FolderArray(i)) & "\")
Call AddSubMPage(SubFolderArray, SubMPageTop, SubMPageLeft,
SubMPageHeight, SubMPageWidth, i)
Call AddButtons(FolderArray(i), SubFolderArray, i + 2)
Next

Call BuildForm

VBA.UserForms.Add(TempForm.Name).Show 'vbModeless
'DoEvents

End Sub
'-------------------------------------------------------------------------------------

Thanks

Brandt



"Jon Peltier" wrote:

When your form is modal, the calling routine stops and waits until the
userform is closed and returns execution to it. When the form is
modeless,
the procedure shows the form, then continues on its merry way.

What works best for a modeless form is to have one procedure that does
everything up to the showing of the form, then ends, and have another
procedure start when the user form is dismissed (i.e., called by the
Close
button code).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
I sure hope someone can help me with this one. I have tried everything
I
know of (which isn't all that much). I have an excel application that
basically creates a series of multi-pages on a userform based on a
directory
hierarchy that it is pointed to. On the multi-pages are buttons for
each
file that exists in the folder that the specific multi-page represents.
What
I have created is just a simple way to access our company's in-house
software
that exists on our server. To do this I had to use what I believe is
called
"design mode" so that the application can create the buttons and add
the
code
for the buttons to the code module. This all works fine, except that
it
has
become apparent that this userform must be modeless so that it can be
left
open. The code I use to call the form is:

VBA.UserForms.Add(TempForm.Name).Show vbModeless

If I leave off the 'vbModeless' portion everything works fine (except
that
the form is modal). With the 'vbModeless' included, the userform is
shown
for about 1/2 a second and closes and all remaining code executes.

Can anyone explain what is going on here? I can, of course, post
additional
code if necessary.

Thanks

Brandt






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Modeless UserForm

Jon,

I am constructing the form as the application runs (on the fly). I believe
that is the cause of the problem. Are you aware of modeless userforms not
working in such a case?

Brandt

"Jon Peltier" wrote:

You're constructing the userform on the fly? I don't know it that has
anything to do with it, I'm just intrigued.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
Jon,

Thanks for your reply. That is exactly what I have (see code below).
I've
used modeless userforms successfully in the past, but I can't get it to
work
in this case.

Here is the code that auto runs when the application is opened.
Everything
after this subroutine is code written as the form is created and should
require user imput to execute.

'----------------------------------------------------------------
Sub OpenFiles()

Dim SubDirectory As String
Dim UserChoice As Variant
Dim FolderArray As Variant
Dim SubFolderArray As Variant
Dim NumOpenApps As Integer
Dim i As Integer
Dim UserDirTest As Integer
Dim ctl As Control

Directory = Sheets("Sheet1").Range("DirDefault").value
UserDirectory = Sheets("Sheet1").Range("DirUser").value

If NumOpenWBs() = 1 Then
Application.Visible = False
Else
ActiveWindow.WindowState = xlMinimized 'application.WindowState =
xlMinimized
End If


Set TempForm = ThisWorkbook.VBProject.VBComponents("UserForm1")

Call Clearform

' Hide VBE window to prevent screen flashing
Application.VBE.MainWindow.Visible = False

FolderArray = GetDirNames(Directory & "\", UserDirectory) 'See mod2 _
UserDirectory Does Not take a "\" Because it is Essentially a Subfolder


'Add Main MultiPage
Call AddMPage(FolderArray, MainMPageTop, MainMPageLeft, MainMPageHeight,
MainMPageWidth)

For i = LBound(FolderArray) To UBound(FolderArray)
SubDirectory = Right(FolderArray(i), Len(FolderArray(i)) -
InStrRev(FolderArray(i), "\")) & "\"
SubFolderArray = GetSubDirNames(CStr(FolderArray(i)) & "\")
Call AddSubMPage(SubFolderArray, SubMPageTop, SubMPageLeft,
SubMPageHeight, SubMPageWidth, i)
Call AddButtons(FolderArray(i), SubFolderArray, i + 2)
Next

Call BuildForm

VBA.UserForms.Add(TempForm.Name).Show 'vbModeless
'DoEvents

End Sub
'-------------------------------------------------------------------------------------

Thanks

Brandt



"Jon Peltier" wrote:

When your form is modal, the calling routine stops and waits until the
userform is closed and returns execution to it. When the form is
modeless,
the procedure shows the form, then continues on its merry way.

What works best for a modeless form is to have one procedure that does
everything up to the showing of the form, then ends, and have another
procedure start when the user form is dismissed (i.e., called by the
Close
button code).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
I sure hope someone can help me with this one. I have tried everything
I
know of (which isn't all that much). I have an excel application that
basically creates a series of multi-pages on a userform based on a
directory
hierarchy that it is pointed to. On the multi-pages are buttons for
each
file that exists in the folder that the specific multi-page represents.
What
I have created is just a simple way to access our company's in-house
software
that exists on our server. To do this I had to use what I believe is
called
"design mode" so that the application can create the buttons and add
the
code
for the buttons to the code module. This all works fine, except that
it
has
become apparent that this userform must be modeless so that it can be
left
open. The code I use to call the form is:

VBA.UserForms.Add(TempForm.Name).Show vbModeless

If I leave off the 'vbModeless' portion everything works fine (except
that
the form is modal). With the 'vbModeless' included, the userform is
shown
for about 1/2 a second and closes and all remaining code executes.

Can anyone explain what is going on here? I can, of course, post
additional
code if necessary.

Thanks

Brandt








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Modeless UserForm

I don't know that it's the cause of your problem.

In my youth I often tried building forms on the fly, but my recent attempts
are much simpler. I usually build in whatever controls I may need, and hide
the ones I'm not using at a particular time. If I do add controls, they are
usually ones intended to hold information but not respond to events.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
Jon,

I am constructing the form as the application runs (on the fly). I
believe
that is the cause of the problem. Are you aware of modeless userforms not
working in such a case?

Brandt

"Jon Peltier" wrote:

You're constructing the userform on the fly? I don't know it that has
anything to do with it, I'm just intrigued.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
Jon,

Thanks for your reply. That is exactly what I have (see code below).
I've
used modeless userforms successfully in the past, but I can't get it to
work
in this case.

Here is the code that auto runs when the application is opened.
Everything
after this subroutine is code written as the form is created and should
require user imput to execute.

'----------------------------------------------------------------
Sub OpenFiles()

Dim SubDirectory As String
Dim UserChoice As Variant
Dim FolderArray As Variant
Dim SubFolderArray As Variant
Dim NumOpenApps As Integer
Dim i As Integer
Dim UserDirTest As Integer
Dim ctl As Control

Directory = Sheets("Sheet1").Range("DirDefault").value
UserDirectory = Sheets("Sheet1").Range("DirUser").value

If NumOpenWBs() = 1 Then
Application.Visible = False
Else
ActiveWindow.WindowState = xlMinimized 'application.WindowState =
xlMinimized
End If


Set TempForm = ThisWorkbook.VBProject.VBComponents("UserForm1")

Call Clearform

' Hide VBE window to prevent screen flashing
Application.VBE.MainWindow.Visible = False

FolderArray = GetDirNames(Directory & "\", UserDirectory) 'See
mod2 _
UserDirectory Does Not take a "\" Because it is Essentially a Subfolder


'Add Main MultiPage
Call AddMPage(FolderArray, MainMPageTop, MainMPageLeft,
MainMPageHeight,
MainMPageWidth)

For i = LBound(FolderArray) To UBound(FolderArray)
SubDirectory = Right(FolderArray(i), Len(FolderArray(i)) -
InStrRev(FolderArray(i), "\")) & "\"
SubFolderArray = GetSubDirNames(CStr(FolderArray(i)) & "\")
Call AddSubMPage(SubFolderArray, SubMPageTop, SubMPageLeft,
SubMPageHeight, SubMPageWidth, i)
Call AddButtons(FolderArray(i), SubFolderArray, i + 2)
Next

Call BuildForm

VBA.UserForms.Add(TempForm.Name).Show 'vbModeless
'DoEvents

End Sub
'-------------------------------------------------------------------------------------

Thanks

Brandt



"Jon Peltier" wrote:

When your form is modal, the calling routine stops and waits until the
userform is closed and returns execution to it. When the form is
modeless,
the procedure shows the form, then continues on its merry way.

What works best for a modeless form is to have one procedure that does
everything up to the showing of the form, then ends, and have another
procedure start when the user form is dismissed (i.e., called by the
Close
button code).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Brandt" wrote in message
...
I sure hope someone can help me with this one. I have tried
everything
I
know of (which isn't all that much). I have an excel application
that
basically creates a series of multi-pages on a userform based on a
directory
hierarchy that it is pointed to. On the multi-pages are buttons for
each
file that exists in the folder that the specific multi-page
represents.
What
I have created is just a simple way to access our company's in-house
software
that exists on our server. To do this I had to use what I believe
is
called
"design mode" so that the application can create the buttons and add
the
code
for the buttons to the code module. This all works fine, except
that
it
has
become apparent that this userform must be modeless so that it can
be
left
open. The code I use to call the form is:

VBA.UserForms.Add(TempForm.Name).Show vbModeless

If I leave off the 'vbModeless' portion everything works fine
(except
that
the form is modal). With the 'vbModeless' included, the userform is
shown
for about 1/2 a second and closes and all remaining code executes.

Can anyone explain what is going on here? I can, of course, post
additional
code if necessary.

Thanks

Brandt








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modeless Userform Roger Excel Programming 2 March 10th 08 08:01 PM
Hide Userform modeless Ger[_3_] Excel Programming 6 May 23rd 07 10:39 AM
Modeless userform hngo New Users to Excel 2 July 13th 05 09:23 AM
modeless userform jacob Excel Programming 1 May 4th 04 02:53 PM
Modeless userform jacob[_3_] Excel Programming 2 September 29th 03 08:02 PM


All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"