How to setup button that will insert a Word file into a Word file

C

CampingClaud

I have a Word 2002 document and at the bottom of page 1 I want to have a
couple buttons where the users can either "Insert a file" or "Insert a
different file". I have tried a hyperlink, but that opens the file in
another document and I need to combine the 2 pages into 1 file.

This form I have could be 3 pages or 20 pages depending on how many pages
the user needs.

HELP --- Can anyone give me a clue here? Claudia
 
J

Jean-Guy Marcil

CampingClaud was telling us:
CampingClaud nous racontait que :
I have a Word 2002 document and at the bottom of page 1 I want to
have a couple buttons where the users can either "Insert a file" or
"Insert a different file". I have tried a hyperlink, but that opens
the file in another document and I need to combine the 2 pages into 1
file.

This form I have could be 3 pages or 20 pages depending on how many
pages the user needs.

HELP --- Can anyone give me a clue here? Claudia

Where you want the user to insert a file, create a MACROBUTTON field:

{MACROBUTTON InsertWordFile "Double click to insert a file."}
(where the {} are inbserted by doinf CTRL-F9).

The use a macro like this:


Sub InsertWordFile()

Dim rgeInsertFile As Range
Dim strFileFullName As String

Set rgeInsertFile = Selection.Range.Paragraphs(1).Range

'-2 = Close
'-1 = OK
'0 = Cancel
'>0 = Other buttons
With Dialogs(wdDialogInsertFile)
Select Case .Display
Case 0
MsgBox "Cancelled by user.", vbInformation, "Cancelled"
Exit Sub
Case -1
strFileFullName = WordBasic.FileNameInfo$(.Name, 1)
End Select
End With

rgeInsertFile.InsertFile FileName:=strFileFullName, Range:="", _
ConfirmConversions:=True, Link:=True, Attachment:=False

End Sub


You may want to change the InsertFile parameters (Linked or not, etc.) , see
the online help on InsertFile for more information.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top