Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open and close excel from word 1

Status
Not open for further replies.

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?
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top