View Single Post
 
Old 02-07-2019, 06:30 AM
MGW1138 MGW1138 is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2019
Posts: 2
MGW1138 is on a distinguished road
Smile How to access Excel from Word

I want to scan a system for open Excel workbooks.

Sub GetExcelData()
Dim WB As Workbook
For Each WB In Application.Workbook
If MsgBox("Do you want " & WB.Name, vbYesNo) = vbYes Then
MsgBox ("Yes")
End If
Next WB
End Sub

The compiler complain and thinks that workbook is a user defined type.
I do have the "Microsoft Office 16.0 Object Library" checked.

What am I missing.

Thanking you in advance (I have done Excel VBA for years but just starting Word)
Reply With Quote