floggingmolly
Board Regular
- Joined
- Sep 14, 2019
- Messages
- 167
- Office Version
- 365
- Platform
- Windows
I have a workbook has a code which loads the path for word templates. It works, but it gives the specific path like C:\User\Me\Mywordtemplates\template1.docx. If the workbook is moved or someone elses uses it, then the template can't be found. The templates are in the same file as the workbook, so I would like to be able to load that filepath then the template name. Below is the code if anyone can help i would appreciate it.
Code:
Sub AddWordTemplate()
Dim WordTempLoc As FileDialog
Dim FirstRow As Long
Set WordTempLoc = Application.FileDialog(msoFileDialogFilePicker)
FirstRow = Sheet2.Range("E99999").End(xlUp).Row + 1 'First Available Row
With WordTempLoc
.Title = "Select Word file to attach"
.Filters.Add "Word Type Files", "*.docx,*.doc", 1
If .Show <> -1 Then GoTo NoSelection
Sheet2.Range("E" & FirstRow).Value = Dir(.SelectedItems(1)) 'Document Name
Sheet2.Range("F" & FirstRow).Value = .SelectedItems(1) 'Document Pathway
End With
NoSelection:
End Sub
Last edited: