View Full Version : Solved: Userform, optionbuttons, and Word
Using XL VBA, I have a userform with multiple option buttons which open and display various Word docs. On first useage after Wb open, the userform remains in front of the Word doc that is to be visible. Following this, each subsequent optionbutton selection presents the Word doc in front of the userform which is what is supposed to happen. Does anyone have any suggestions as to why this occurs or how I can ensure that the Word doc is always displayed in front of the userform? Dave
mvidas
11-16-2006, 10:24 AM
Hi Dave,
Just a guess without seeing your code, but maybe this will do it ? YourWordAppVariable.ActivateMatt
Thanks Matt but that produced an error unless I misunderstood (I placed wdapp2.activate before wdapp2.visible in the code below). Seems like fairly straight forword code and it works as expected other than initially. Dave
Set Wdapp2 = CreateObject("Word.Application")
Wdapp2.ChangeFileOpenDirectory "C:\records"
Wdapp2.documents.Open Filename:="summary.doc"
With Wdapp2.Selection
Wdapp2.Visible = True
End With
mvidas
11-16-2006, 11:49 AM
Unless you have more in that With block, you don't need it.
I would try something like:Set Wdapp2 = CreateObject("Word.Application")
Wdapp2.Visible = True
Wdapp2.ChangeFileOpenDirectory "C:\records"
Wdapp2.Documents.Open FileName:="summary.doc"
Wdapp2.ActivateBut you could also do (again, unless you have more code)Set Wdapp2 = CreateObject("Word.Application")
Wdapp2.Visible = True
Wdapp2.Documents.Open FileName:="C:\records\summary.doc"
Wdapp2.ActivateMatt
Thanks again Matt. This was an easier fix than I had thought. Interestingly, using activate following this code brought the userform to the foreground. It's a fix! Thanks again, I'll mark this solved. Dave
Set Wdapp2 = CreateObject("Word.Application")
Wdapp2.Visible = True
Wdapp2.Documents.Open Filename:="C:\records\summary.doc"
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.