From: Marley on
Can anyone help me please? I need a macro which allows me to insert text from
whichever file I choose from a directory.

The idea is to click on a toolbar icon > display the folder containing the
text files > select the text file > Click to insert file. The trouble is I
could do it on my home PC but could not do it on my work network.

I used the macro from a previous post and it was great but I seem to have
trouble with the insert part of the macro and it includes both the S: path
and the C: temp path when asking me if I'm sure this is the file I want.

Macro used:
Sub MySpecFileInsert()
defPath = Options.DefaultFilePath(wdDocumentsPath)
Options.DefaultFilePath(wdDocumentsPath) = "S:\Insert"

Set myDialog = Dialogs(wdDialogInsertFile)

If myDialog.Display = -1 Then
tempPath = Options.DefaultFilePath(wdDocumentsPath)
If tempPath = "s:\insert" Then
myDialog.Execute
Else
x = MsgBox("Are you sure you want to insert " & tempPath _
& "\" & myDialog.Name, vbYesNo)
If x = 6 Then
myDialog.Execute
End If
End If
End If

Options.DefaultFilePath(wdDocumentsPath) = defPath
End Sub


Thanks!

From: Doug Robbins - Word MVP on
Try the following:

Dim fd As FileDialog
Dim FiletoInsert As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Title = "Select the File that you want to insert"
.InitialFileName = "S:\Insert\*.doc*"
.AllowMultiSelect = False
If .Show = -1 Then
FiletoInsert = .SelectedItems(1)
X = MsgBox("Are you sure that you want to insert " &
FiletoInsert & at the location of the selection?", vbYesNo + vbQuestion)
If X = vbYes Then
Selection.Range.InsertFile FiletoInsert
End If
End If
End With
Set fd = Nothing


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Marley" <Marley(a)discussions.microsoft.com> wrote in message
news:02A859A5-351C-4BB7-8E2F-50BFEC91B9EF(a)microsoft.com...
> Can anyone help me please? I need a macro which allows me to insert text
> from
> whichever file I choose from a directory.
>
> The idea is to click on a toolbar icon > display the folder containing the
> text files > select the text file > Click to insert file. The trouble is I
> could do it on my home PC but could not do it on my work network.
>
> I used the macro from a previous post and it was great but I seem to have
> trouble with the insert part of the macro and it includes both the S: path
> and the C: temp path when asking me if I'm sure this is the file I want.
>
> Macro used:
> Sub MySpecFileInsert()
> defPath = Options.DefaultFilePath(wdDocumentsPath)
> Options.DefaultFilePath(wdDocumentsPath) = "S:\Insert"
>
> Set myDialog = Dialogs(wdDialogInsertFile)
>
> If myDialog.Display = -1 Then
> tempPath = Options.DefaultFilePath(wdDocumentsPath)
> If tempPath = "s:\insert" Then
> myDialog.Execute
> Else
> x = MsgBox("Are you sure you want to insert " & tempPath _
> & "\" & myDialog.Name, vbYesNo)
> If x = 6 Then
> myDialog.Execute
> End If
> End If
> End If
>
> Options.DefaultFilePath(wdDocumentsPath) = defPath
> End Sub
>
>
> Thanks!
>