• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 638
  • Last Modified:

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
0
wbaker57
Asked:
wbaker57
  • 3
  • 2
1 Solution
 
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
 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now