|
-
Sep 6th, 2006, 05:34 PM
#1
UserForm restricted to Excel Application Window
Hi Guys,
Brain has not initialised today.
After displaying an Excel (2003/XP) UserForm as Modal, how can I keep it within the Excel Application window? IE. It can't be moved outa the appliaction window....
Cheers,
Last edited by Bruce Fox; Sep 6th, 2006 at 06:53 PM.
-
Sep 6th, 2006, 05:55 PM
#2
Re: UserForm restricted to Excel Application Window
Sup Bruce! 
This is about as close as you can easily get. It still goes behind the command bars and over the task pane but its limited to the Excel application window.
VB Code:
Option Explicit
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Sub Workbook_Open()
Dim lHwnd As Long
UserForm1.Show vbModeless
lHwnd = FindWindow("ThunderDFrame", "UserForm1")
SetParent lHwnd, Application.Hwnd
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 6th, 2006, 06:16 PM
#3
Re: UserForm restricted to Excel Application Window
Hey Rob,
Thanks for the reply.
I guessed that may be it, but thought I was overlooking the obvious 
Bruce.
-
Sep 6th, 2006, 06:52 PM
#4
Re: [Resolved] UserForm restricted to Excel Application Window
Hmmm dosn't seem to work with Modal.....
-
Sep 6th, 2006, 06:59 PM
#5
Re: UserForm restricted to Excel Application Window
Show the userform modaless to get its window handle. Then hide it and reshow it as modal. See if the handle remains the same.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 6th, 2006, 07:17 PM
#6
Re: UserForm restricted to Excel Application Window
Showing it modally after its set as a child wont work after all as once its a child it becomes disabled due to the modality factor.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 6th, 2006, 08:56 PM
#7
Re: UserForm restricted to Excel Application Window
Trying a few other options aswell
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|