#1
|
|||
|
|||
Opening Excel from Word
Good evening. I'm hoping someone here can give me some help with what I assume is a relatively simple VBA programming challenge, but which is well beyond my VBA capabilities.
I am trying to create a macro that performs the following actions.
I understand that the VBA needs to be embedded in the Microsoft Word Objects "ThisDocument" section of VBA. I've tried a number of scripts that I've found online which include the use of Objects (things like Dim excelApp As Excel.Application), but I always get a runtime error. Really hoping someone can give me a bit of an idiots guide to getting the basic structure of this set up. Any help greatly appreciated. Jake |
#2
|
||||
|
||||
Code like:
Dim excelApp As Excel.Application indicates the use of early binding. Did you set a reference to Excel in the VBE, via Tools|References?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
I've added MS Excel Objects and it now works and opens the file, but only if specifically run rather than automatically. My code is currently as follows:
Code:
PrivateSub runOnOpen Call openExcel Call UpdateAllFields End Sub Sub openExcel() Dim excelApp As Excel.Application Dim openExcel As Workbook Dim var1 As Integer Set excelApp = New Excel.Application Set openExcel = excelApp.Workbooks.Open("filename") excelApp.Visible = True End Sub Sub UpdateAllFields() Application.DisplayAlerts = False ActiveDocument.Fields.Update Application.DisplayAlerts = True End Sub |
#4
|
||||
|
||||
Cross-posted at: https://stackoverflow.com/questions/...file-from-word
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
||||
|
||||
You should look at the topic of auto macros for Word; Your 'runOnOpen' macro is named incorrectly for that.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
vba word |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Opening word document from excel 2013 | Aurelius | Excel Programming | 1 | 03-12-2017 01:47 PM |
Opening excel from word | AXbean | Word VBA | 2 | 02-26-2017 12:59 AM |
Hyperlinks error msg on opening in Excel, Word | matilda | Excel | 3 | 05-04-2015 07:06 AM |
Word Document Not Opening With Excel VBA | JennEx | Word VBA | 3 | 06-20-2013 10:10 AM |
Slow Opening Word and Excel files | itoa | Office | 1 | 05-11-2009 02:01 PM |