Discussion Locked

Macro needed for Word2000

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am using Word2000 to prepare my students for the MOUS exam. For practice purposes I set up 6 sets of 50-55 tasks. Each task consists of one document. The students start by opening question 1; when they finish the task they click on a NEXT hyperlink at the bottom of the page and the next question opens, etc...

In Word2000 you get a new window for each open document, which clutter up the task bar and the students have to close all the questions at the end, which can be a bit tedious.

Does anyone know a macro which, on clicking the hyperlink, would open the next document and close the finished one?

10 replies

by stuff

I can't help you with a macro at this time, but in Word if you....

with the SHIFT key pressed click on File, you have a new item called 'close all'

This will close all documents with one action.

Hope this helps.

Chris

by laurent_k

That's what I have told them to do so far. But as they don't have to save most tasks, they have to click on Yes or No to save changes for each one.

by mbazzell

Before your students begin, have them open one occurrence of word on their machine. Make sure all documents are closed in word and just the application is open. Then as they click on the next button it should continue to use that one occurrence ofWord.

by mbazzell

Before your students begin, have them open one occurrence of word on their machine. Make sure all documents are closed in word and just the application is open. Then as they click on the next button it should continue to use that one occurrence ofWord.

by sankulpune

Hello Laurent_k,

Here is what you need.

1) Open a new instance of WORD 2000.
2) Click on Tools > Macro > Visual Basic Editor
3) In the VBE (Visual Basic Editor) in the Project Explorer double click on 'ThisDocument' under 'Microsoft Word Object' under the inside the "Normal'.
4) Copy and paste following text in the right pane.

'======
Private Sub Document_New()

ClosePrevDocs

End Sub

Private Sub Document_Open()

ClosePrevDocs

End Sub
Private Sub ClosePrevDocs()

Dim ClosePyn As Integer
ClosePyn = MsgBox("Click 'Yes' to close all previous documents.", vbYesNo, "Close Previous Documrnts")

If ClosePyn = vbYes Then

Dim TotDocs As Byte, Kounter As Integer Dim Docs As Documents

Set Docs = ThisDocument.Application.Documents
TotDocs = Docs.Count

For Kounter = TotDocs To 2 Step -1

Docs(Kounter).Close (wdPromptToSaveChanges)
Next Kounter

End If

End Sub
'=======

I hope this helps.

Should you need any clarifications / more help; please do not hesitate to contact.

With kind regards,

Sanjay Kulkarni
'Simple Solutions To Small Problems, no QuickFixes.'

by laurent_k

Excellent - More or less what I was looking for! A bit of tweaking for my needs and that's it. Thanks very much.

This discussion is closed to new replies.