matthoward
New Member
- Joined
- Aug 11, 2017
- Messages
- 1
Hi All,
I want to pull data from a excel spreadsheet and put it into a word document. At the moment, I have created a Label and gone into its properties and named it 'yrTotal'. I have also put a Command Button into the word document and gone into VBA Editor for it. I have made sure is Microsoft Excel 14.0 Object Library selected. I have been given the following example code from a website, but it is not tailored to my files:
However I want to pull data from the Spreadsheet called 'reference' from 'Sheet 1' and cell 'A1', and to get to that file from 'File Explorer' you need to follow the path:
Any help would be much appreciated in providing the coding
Thanks
Matt
I want to pull data from a excel spreadsheet and put it into a word document. At the moment, I have created a Label and gone into its properties and named it 'yrTotal'. I have also put a Command Button into the word document and gone into VBA Editor for it. I have made sure is Microsoft Excel 14.0 Object Library selected. I have been given the following example code from a website, but it is not tailored to my files:
Code:
Private Sub CommandButton1_Click()
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
Set exWb = objExcel.Workbooks.Open("c:\temp\expenses.xls")
ThisDocument.yrTotal.Caption = exWb.Sheets("Sheet1").Cells(12, 2)
exWb.Close
Set exWb = Nothing
End Sub
Code:
This PC, Personal Area (H:), 2017, Forecasting SS, reference
Any help would be much appreciated in providing the coding
Thanks
Matt
Last edited by a moderator: