EMONTES149
New Member
- Joined
- Dec 20, 2016
- Messages
- 8
i am trying to automate the selection of 300 master documents into a project specific directory. The directory path changes per project, so it is important that the end user selects the folder. I am in word and am trying to use the msoFileDialogFolderPicker to select the current directory. It works well with "msoFiuleDialogFilePicker" but I have to select a file for the rest of the code to work. I would rather have the end user select the folder and not have to select a file. I would appreciate any help I can get. I am not a programmer, just an architect trying to be one.
Below is the code I am using.
Sub CreatingRelativeSubDocuments()
Dim fldr As FileDialog
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
On Error Resume Next
FolderName = .SelectedItems(1)
Err.Clear
On Error GoTo 0
End With
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
ActiveWindow.ActivePane.View.Type = wdOutlineView
If ActiveWindow.View = wdMasterView Then
ActiveWindow.View = wdOutlineView
Else
ActiveWindow.View = wdMasterView
End If
Selection.Range.Subdocuments.AddFromFile Name:="011000 - summary.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012100 - allowances.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012200 - unit prices.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012200 - unit prices.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012300 - alternates.docx"
Selection.Range.Subdocuments.AddFromFile Name:="013100 - Project Management and Coordination.docx"
End Sub
Below is the code I am using.
Sub CreatingRelativeSubDocuments()
Dim fldr As FileDialog
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
On Error Resume Next
FolderName = .SelectedItems(1)
Err.Clear
On Error GoTo 0
End With
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
ActiveWindow.ActivePane.View.Type = wdOutlineView
If ActiveWindow.View = wdMasterView Then
ActiveWindow.View = wdOutlineView
Else
ActiveWindow.View = wdMasterView
End If
Selection.Range.Subdocuments.AddFromFile Name:="011000 - summary.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012100 - allowances.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012200 - unit prices.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012200 - unit prices.docx"
Selection.Range.Subdocuments.AddFromFile Name:="012300 - alternates.docx"
Selection.Range.Subdocuments.AddFromFile Name:="013100 - Project Management and Coordination.docx"
End Sub