-
Try this:
[vba]
'Requires a referece to the Microsoft Excel Object Library
'Tools | References
Option Explicit
Sub ExcelMacro()
Dim ObjExcel As Excel.Application
Dim Wkb As Excel.Workbook
Dim WS As Excel.Worksheet
Dim Path As String
Dim FName As String
Path = ThisDocument.Path
FName = "Book1.xls"
Set ObjExcel = New Excel.Application
'ObjExcel.Visible = True 'Add this line to make the Excel app visible
Set Wkb = ObjExcel.Workbooks.Open(FileName:=Path & "\" & FName)
Set WS = Wkb.Sheets("Sheet1")
WS.Range("A1").Value = "This"
WS.Range("A2").Value = "Is"
WS.Range("A3").Value = "A"
WS.Range("A4").Value = "Message"
WS.Range("A5").Value = "From"
WS.Range("A6").Value = "Word"
Wkb.Close True
ObjExcel.Quit
Set ObjExcel = Nothing
Set Wkb = Nothing
Set WS = Nothing
End Sub
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules