wbaker57
asked on
EASY - Activate windows in Office2000
IN Word I have a dialog box which launches templates through the use of Option buttons – (See macro below). This has worked fine in Office97. Now we have switched to Office 2000. In 2000 the new documents are launched in separate windows and we have to manually activate the new doc. I need to add a statement to activate the new window.
Help!!!!
300 PTS FOR FAST RESPONSE. - THANKS
Private Sub CmdOK_Click()
If Opt_DecOpt = True Then
Documents.Add Template:="c:\office2000\t emplates\D ecOpt.dot" , NewTemplate:=False
ActiveWindow.ActivePane.Vi ew.Type = wdPageView
ActiveWindow.ActivePane.Vi ew.Zoom.Pa geFit = wdPageFitBestFit
ElseIf Opt_DruFre = True Then
Documents.Add Template:="c:\office2000\t emplates\D ruFre.dot" , NewTemplate:=False
ActiveWindow.ActivePane.Vi ew.Type = wdPageView
ActiveWindow.ActivePane.Vi ew.Zoom.Pa geFit = wdPageFitBestFit
Else:
Unload FormDialog
End If
End
End Sub
Help!!!!
300 PTS FOR FAST RESPONSE. - THANKS
Private Sub CmdOK_Click()
If Opt_DecOpt = True Then
Documents.Add Template:="c:\office2000\t
ActiveWindow.ActivePane.Vi
ActiveWindow.ActivePane.Vi
ElseIf Opt_DruFre = True Then
Documents.Add Template:="c:\office2000\t
ActiveWindow.ActivePane.Vi
ActiveWindow.ActivePane.Vi
Else:
Unload FormDialog
End If
End
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
dhwanilshah
I modified your code for the PageFit view and put in the path for the template (below) but the results are still the same as before. Still having to manually activate.
You evidently have it working for you...What am I missing here?
Many thanks
Dim mDoc As Document
Set mDoc = Documents.Add("c:\office20 00\templat es\DecOpt. dot", , , True)
mDoc.ActiveWindow.ActivePa ne.View = wdPageView
mDoc.ActiveWindow.ActivePa ne.Zooms(w dPageView) .PageFit = wdPageFitBestFit
I modified your code for the PageFit view and put in the path for the template (below) but the results are still the same as before. Still having to manually activate.
You evidently have it working for you...What am I missing here?
Many thanks
Dim mDoc As Document
Set mDoc = Documents.Add("c:\office20
mDoc.ActiveWindow.ActivePa
mDoc.ActiveWindow.ActivePa
This code works fine here,
but still,
try this :
mDoc.Activate
put this line just after creating a new document based on a template i.e. after
Set mDoc=.....
also if this does not work, then please give me a scenario as to how u r using the macro. Here I tried it out this way : I made the macro, opened a couple of new documents, ran the macro from an document, and then the new document opened up quite fine. Also try this, just try and check this code out as it is, i.e. without adding any of your other dialog based code, if it works then there must be some problem bec. of the dialog box, i am not sure but this is the way to debug this problem
but still,
try this :
mDoc.Activate
put this line just after creating a new document based on a template i.e. after
Set mDoc=.....
also if this does not work, then please give me a scenario as to how u r using the macro. Here I tried it out this way : I made the macro, opened a couple of new documents, ran the macro from an document, and then the new document opened up quite fine. Also try this, just try and check this code out as it is, i.e. without adding any of your other dialog based code, if it works then there must be some problem bec. of the dialog box, i am not sure but this is the way to debug this problem
ASKER
dhwanilshah
Thanks for all your help. Actually, your code works without the dialog box as a raw macro. The problem was unloading the dialog box after executing the document launch. Unloading the dialog after launching the newDoc evidently gives focus to the original window, therefore nullifying the Activate statement that came before.
I placed the unload statment before launching the doc (below) and it activates the new doc just fine. PROBLEM SOLVED and in time for work Monday. 1/3/2000
Thanks for all your help!
If Opt_DecOpt = True Then
Unload FormDialog
Dim mDoc As Document
Set mDoc = Documents.Add
"c:\office2000\templates\D ecOpt.dot" , , , True)
mDoc.Activate
mDoc.ActiveWindow.ActivePa ne.View = wdPageView
mDoc.ActiveWindow.ActivePa ne.Zooms(w dPageView) .PageFit = wdPageFitBestFit
Thanks for all your help. Actually, your code works without the dialog box as a raw macro. The problem was unloading the dialog box after executing the document launch. Unloading the dialog after launching the newDoc evidently gives focus to the original window, therefore nullifying the Activate statement that came before.
I placed the unload statment before launching the doc (below) and it activates the new doc just fine. PROBLEM SOLVED and in time for work Monday. 1/3/2000
Thanks for all your help!
If Opt_DecOpt = True Then
Unload FormDialog
Dim mDoc As Document
Set mDoc = Documents.Add
"c:\office2000\templates\D
mDoc.Activate
mDoc.ActiveWindow.ActivePa
mDoc.ActiveWindow.ActivePa
ASKER
I modified your code for the PageFit view and put in the path for the template (below) but the results are still the same as before. Still having to manually activate.
You evidently have it working for you...What am I missing here?
Many thanks
Dim mDoc As Document
Set mDoc = Documents.Add("c:\office20
mDoc.ActiveWindow.ActivePa
mDoc.ActiveWindow.ActivePa