#1
|
|||
|
|||
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) |
#2
|
||||
|
||||
A Workbook is an object that requires the Microsoft Excel Object Library. Try ticking that one instead. However it will still have a problem because Application.Workbook in this instance is going to be Microsoft Word and it doesn't contain Workbooks.
Do a google search for "VBA GetObject application excel" if you are trying to access open workbooks from Word.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Also, the Workbooks collection only deals with workbooks which are open in Excel. Is this what you want?
Otherwise, you would be searching the file system for .xlsx files (and xlsm and xls files?). |
Tags |
excel to word |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel or Access | hollies | Excel | 17 | 07-18-2017 03:21 AM |
Excel or Access for DB? | John H. Power | Word | 3 | 08-03-2016 11:52 AM |
How to access Excel worksheet data from Word | jules43 | Word VBA | 1 | 03-23-2016 02:36 AM |
Moving addresses from a letter in word into access or excel | docwilll | Office | 3 | 02-22-2014 03:40 PM |
Excel to Access to Excel for report automation | Nicholaspoe | Excel Programming | 10 | 10-08-2013 08:13 PM |