Mar 6, 2002 #1 ETID Programmer Jul 6, 2001 1,867 US I can't remember the code to open and close (without prompts to save) an excel xls from within a word vba sub. anyone?
I can't remember the code to open and close (without prompts to save) an excel xls from within a word vba sub. anyone?
Mar 6, 2002 1 #2 JustinEzequiel Programmer Jul 30, 2001 1,192 PH Option Explicit Sub test() Dim oXL As Excel.Application Dim oWB As Excel.Workbook Dim sFile As String sFile = "C:\My Documents\OT.xls" Set oXL = CreateObject("Excel.Application" Set oWB = oXL.Workbooks.Open(sFile) ' do whatever you want with the open workbook here ' ex. Debug.Print oWB.BuiltInDocumentProperties("Author" oWB.Saved = True oWB.Close Set oWB = Nothing Set oXL = Nothing End Sub Upvote 0 Downvote
Option Explicit Sub test() Dim oXL As Excel.Application Dim oWB As Excel.Workbook Dim sFile As String sFile = "C:\My Documents\OT.xls" Set oXL = CreateObject("Excel.Application" Set oWB = oXL.Workbooks.Open(sFile) ' do whatever you want with the open workbook here ' ex. Debug.Print oWB.BuiltInDocumentProperties("Author" oWB.Saved = True oWB.Close Set oWB = Nothing Set oXL = Nothing End Sub