Link to home
Start Free TrialLog in
Avatar of wbaker57
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\templates\DecOpt.dot", NewTemplate:=False
        ActiveWindow.ActivePane.View.Type = wdPageView
        ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit
   
    ElseIf Opt_DruFre = True Then
        Documents.Add Template:="c:\office2000\templates\DruFre.dot", NewTemplate:=False
        ActiveWindow.ActivePane.View.Type = wdPageView
        ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit

    Else:
    Unload FormDialog
    End If
    End
   
End Sub
ASKER CERTIFIED SOLUTION
Avatar of dhwanilshah
dhwanilshah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wbaker57
wbaker57

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:\office2000\templates\DecOpt.dot", , , True)
        mDoc.ActiveWindow.ActivePane.View = wdPageView
        mDoc.ActiveWindow.ActivePane.Zooms(wdPageView).PageFit = wdPageFitBestFit
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:\office2000\templates\DecOpt.dot", , , True)
        mDoc.ActiveWindow.ActivePane.View = wdPageView
        mDoc.ActiveWindow.ActivePane.Zooms(wdPageView).PageFit = wdPageFitBestFit
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
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\DecOpt.dot", , , True)
        mDoc.Activate
        mDoc.ActiveWindow.ActivePane.View = wdPageView
        mDoc.ActiveWindow.ActivePane.Zooms(wdPageView).PageFit = wdPageFitBestFit