|
|
Making a UserForm show above a any opened doc
Hi,
I am using a userform to load document into Word, but when the
document is opened, the userform window will be covered by the opened
file. This happens whether the ShowModal property is set to True or
False.
I checked online and found this posted by Doug:
Making a UserForm show above a newly created Word 2000+
http://www.word.mvps.org/FAQs/Userforms/KeepUserFmAboveDoc.htm
but the link is removed. :(
I also tried to minimize the newly opened file with the following
code:
wrdDoc.Windows(1).WindowState = wdWindowStateMinimize
(The wrdDoc is the file object and I verified the wrdDoc.Name as the
file name.)
but it does not get minimized. However, when I use
activedocument.Windows(1).WindowState = wdWindowStateMinimize, it
works on the document which is running the code.
Could any one help? (I need to know how to make the userform appear
at front and how to minimize a opened doc with VBA.)
Anthony
|
|
0
|
|
|
|
Reply
|
Anthony
|
2/23/2010 6:24:40 PM |
|
Try the link again. It just worked here.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Anthony" <excelmodeling@gmail.com> wrote in message
news:5734e5e7-dbed-4691-b922-d91be5e4fccb@o3g2000vbo.googlegroups.com...
> Hi,
>
> I am using a userform to load document into Word, but when the
> document is opened, the userform window will be covered by the opened
> file. This happens whether the ShowModal property is set to True or
> False.
>
> I checked online and found this posted by Doug:
>
> Making a UserForm show above a newly created Word 2000+
> http://www.word.mvps.org/FAQs/Userforms/KeepUserFmAboveDoc.htm
>
> but the link is removed. :(
>
>
> I also tried to minimize the newly opened file with the following
> code:
>
> wrdDoc.Windows(1).WindowState = wdWindowStateMinimize
>
> (The wrdDoc is the file object and I verified the wrdDoc.Name as the
> file name.)
>
> but it does not get minimized. However, when I use
> activedocument.Windows(1).WindowState = wdWindowStateMinimize, it
> works on the document which is running the code.
>
> Could any one help? (I need to know how to make the userform appear
> at front and how to minimize a opened doc with VBA.)
>
> Anthony
|
|
0
|
|
|
|
Reply
|
Doug
|
2/23/2010 7:53:01 PM
|
|
Thank you so much for your help. The code is cool and works well.
Can the following code be placed in a sub in a module (and not in a
form)?
====================================
Option Explicit
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub CommandButton1_Click()
Dim iHandleForm As Long
Dim iHandleDoc As Long
Dim iNull As Long
Dim oDoc As Document
iHandleForm = GetActiveWindow()
Set oDoc = Documents.Add
iHandleDoc = GetActiveWindow()
iNull = SetParent(iHandleForm, iHandleDoc)
oDoc.Activate
End Sub
====================================
If it is doable, how can I make the change to accommodate for that?
(Because I have the
Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
process in a sub already and I am hesitate to move it into the form.)
Anthony
|
|
0
|
|
|
|
Reply
|
Anthony
|
2/24/2010 12:43:52 AM
|
|
|
2 Replies
596 Views
(page loaded in 0.037 seconds)
Similiar Articles: Making a UserForm show above a any opened doc - microsoft.public ...Hi, I am using a userform to load document into Word, but when the document is opened, the userform window will be covered by the opened file. T... Making a document open a userform in the originating template ...Making a UserForm show above a any opened doc - microsoft.public ... (I need to know how to make the userform appear > at ... Stopping prompt to save template when doc is ... How do you make a userform open automatically when you open excel ...Making a UserForm show above a any opened doc - microsoft.public ... How do you make a userform open automatically when you open excel ... Making a UserForm show above a ... Opening a user form - microsoft.public.word.vba.general ...Making a UserForm show above a any opened doc - microsoft.public ... Also if I bypass the front page dialog, and use the buttons embeded in the worksheet I can still open ... Sub or Function not defined (Why ??) - microsoft.public.word.vba ...Sub or Function not defined (Why ??) - microsoft.public.word.vba ... Making a UserForm show above a any opened doc - microsoft.public ... Sub or Function not defined ... How do you automatically display a vba form in excel 2007 ...... as: Sub Button_Click() userFormName.Show ... work with the Unload Me still in the code above ... How do you make a userform open automatically when you open excel ... Automatic Userform Excel 2003 - microsoft.public.excel.misc ...Automatic Userform Excel 2003 - microsoft.public.excel.misc ... Word 97-2003 doc format allows access to the field ... Making a UserForm show above a any opened doc ... why does Word display my field codes upon opening? - microsoft ...Making a UserForm show above a any opened doc - microsoft.public ... Can the following code be placed in a sub in a module (and not in a form)? ... Excel :: Show UserForm ... Lookup to create List - microsoft.public.excel.miscCreating a lookup in a userform - microsoft.public.excel.misc ... Making a UserForm show above a any opened doc - microsoft.public ... MSGROUPS.NET Search ... show minimize window selection for Excel - microsoft.public.excel ...Making a UserForm show above a any opened doc - microsoft.public ..... Name as the file name.) but it does not get minimized. However, when I use activedocument.Windows(1 ... Making a UserForm show above a any opened doc - microsoft.public ...Hi, I am using a userform to load document into Word, but when the document is opened, the userform window will be covered by the opened file. T... Making a document open a userform in the originating template ...Making a UserForm show above a any opened doc - microsoft.public ... (I need to know how to make the userform appear > at ... Stopping prompt to save template when doc is ... Build a UserForm for Excel... same techniques to create a UserForm in any ... Fig. 1 The finished UserForm project. NOTE: The screenshots here show how ... you have seen, it is easy to open the UserForm ... Excel - Set Focus Back To Workbook While Form Is Active - I have a ...... to hide the userform too, but when i need to show it ... back to the Doc to ... I am trying to make the above code to close the active userform (while the workbook is still open ... Excel :: Show UserForm Upon Opening File/Workbook... then it does not show. I need the userform to be a part of the excel which I open. not ... alone the line, how to make just ... miss the ".xls" or ".doc" at the end (see above). 7/24/2012 11:35:48 AM
|
|
|
|
|
|
|
|
|