I have a Word VBA macro that transfers data from specific cells in an open excel workbook to bookmarks in a word document.
Ideally, I would be able to press a button which opens a file dialog, allowing me to select the excel file upon which to run the macro (setting it to be the active workbook, calling my other macro, then closing the workbook should work(?))
I have a simple piece of code which brings up the file dialog, but does not open the selected file, nor can it call on my other macro.
Code: Select all
Private Sub Browsefile()
On Error Resume Next
Dim strFile As String
Set x1App = GetObject(Class:="Excel.Application")
Dim xlwbk As Object
With Application.FileDialog(1)
.Filters.Clear
.Filters.Add "Excel workbooks", "*.xls*"
If .Show Then
strFile = .SelectedItems(1)
Else
Beep
Exit Sub
End If
End With
End Sub
Matt