FredrikNilsen
New Member
- Joined
- Jan 25, 2021
- Messages
- 26
- Office Version
- 365
- 2019
- 2016
- 2013
- Platform
- Windows
Not sure if this is better posted in a Word VBA forum, but I'll try here first:
I have a Word template, and I want to have a macro to open the file dialogue, select an Excel file, select all data in Sheet1, and copy and paste it to a bookmark ("Data") in the Word template (the data should probably not be linked). I have this code for the first part, but I'm not sure how to approach the rest.
I have a Word template, and I want to have a macro to open the file dialogue, select an Excel file, select all data in Sheet1, and copy and paste it to a bookmark ("Data") in the Word template (the data should probably not be linked). I have this code for the first part, but I'm not sure how to approach the rest.
VBA Code:
Sub SelectExcelFile()
Dim xlApp As Excel.Application
Dim xlWbk As Excel.Workbook
Dim strFile As String
strFile = Excel.Application.GetOpenFilename()
Workbooks.Open (strFile)
Set xlApp = Excel.Application
xlApp.Visible = False
End Sub