Hey there,
I have an add in that added a control button in the ribbon but i am unsure how to script the desire outcome.
I have a file path which housed multiple data transfer files......ideally i want the button in the ribbon to open the file path then when the user chooses one of the many DTFs in the folder path i want it to open it in that program. Currently it opens the selected DTF in the active worksheet.
Does that make sense? Heres is the current code which is trigger when the user select the button.
I have an add in that added a control button in the ribbon but i am unsure how to script the desire outcome.
I have a file path which housed multiple data transfer files......ideally i want the button in the ribbon to open the file path then when the user chooses one of the many DTFs in the folder path i want it to open it in that program. Currently it opens the selected DTF in the active worksheet.
Does that make sense? Heres is the current code which is trigger when the user select the button.
Code:
Sub OpenDTFTemplates(control As IRibbonControl)
Dim Filter As String, Title As String
Dim FilterIndex As Integer
Dim Filename As Variant
' File filters
Filter = "Excel Files (*.xls),*.xls," & _
"Text Files (*.txt),*.txt," & _
"All Files (*.*),*.*"
' Default Filter to *.*
FilterIndex = 3
' Set Dialog Caption
Title = "Select a File to Open"
' Select Start Drive & Path
ChDrive ("G")
ChDir ("G:\MyPath\DTFs")
With Application
' Set File Name to selected File
Filename = .GetOpenFilename(Filter, FilterIndex, Title)
' Reset Start Drive/Path
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
' Exit on Cancel
If Filename = False Then
'MsgBox "No file was selected."
Exit Sub
End If
' Open File
Workbooks.Open Filename
'MsgBox Filename, vbInformation, "File Opened" ' This can be removed
End Sub