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
wbaker57Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dhwanilshahCommented:
here is a code snippet I just developed using the new word 2000 vba


Dim mDoc As Document

Set mDoc = Documents.Add("LT SS P", , , True)

mDoc.ActiveWindow.ActivePane.View = wdNormalView
mDoc.ActiveWindow.ActivePane.Zooms(wdNormalView).PageFit = wdPageFitBestFit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wbaker57Author Commented:
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
0
wbaker57Author Commented:
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
0
dhwanilshahCommented:
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
0
wbaker57Author Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.