16
Moderator
#1
Open word, insert a label from Design mode (in developer tab)

Insert Button

Double click on button, in VBA editor; go to Tools -> References-> tick Microsoft excel 
objects and controls (similar)

Add below code (for button)

Private Sub CommandButton1_Click()
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
Set exWb = objExcel.Workbooks.Open("d:\excel.xlsx")
ThisDocument.prjno.Caption = exWb.Sheets("Sheet1").Cells(6, 2)
exWb.Close
Set exWb = Nothing
End Sub
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)