icon to open two files

  • Thread starter Thread starter Howard
  • Start date Start date
Yes. Are these the same documents each and every time? Will they be in the
same directory every time you need them? Or will they be two or more
documents based on some other criteria that may change from time to time?

Ed
 
Here's how I did it. Won't say it's the best way, but it works for me.

(1) Open a new document in Word. Hold the ALT key and hit F11.

(2) In the Project Explorer on the left edge (if you don't see it, hit
Ctrl+R), find "Project(New Document)".
Below that is a Wrod icon with ThisDocument next to it. Double-click that
icon.

(3) In the window on the right, there will be two drop-down lists on top.
Change the leeft one to read Document and the right one to read Open. In
the window, you should see:
Private Sub Document_Open()

End Sub

(4) Copy the code that follows and paste it in between those two lines.

Dim doc1 As Document
Dim doc2 As String
Dim doc3 As String

Set doc1 = ActiveDocument
doc2 = _
"PUT DOC NAME HERE"
doc3 = _
"PUT DOC NAME HERE"

Documents.Open FileName:=doc2
Documents.Open FileName:=doc3

doc1.Close

(5) Get the full path and name of your two documents - everything from C:\
to .doc. Put these in the code to replace PUT DOC NAME HERE.

(6) Close the code window with the X in the corner. Save the NewDoc to your
desktop with whatever name you want.

That should do it. Opening that doc should open your other two and close
the "icon" doc. You may have to deal with a warning to enable macros each
time you open this; that's normal, and it's a small price to pay to avoid
macro viruses.

If you have any other problems, copy the entire code from Private Sub to End
Sub and post it here. Someone will find the problem (and kick me for it,
I'm sure!).

HTH
Ed
 
Howard:

Let's change that a bit. Use this code instead. I changed the references
to doc1, which is to be your "IconDoc". The other way, it was possible for
the ActiveDocument to grab a doc already open and force *it* to close. This
way, it gets the file name of the doc you're opening and uses that to close
itself.

Dim doc1 As String
Dim doc2 As String
Dim doc3 As String

doc1 = ThisDocument.FullName

doc2 = _
"PUT DOC NAME HERE"
doc3 = _
"PUT DOC NAME HERE"

Documents.Open FileName:=doc2
Documents.Open FileName:=doc3

Documents.Close FileName:=doc1

Ed
 
Back
Top