Article ID: 126098
Article Last Modified on 10/11/2006
Sub To_Excel()
AppActivate "Microsoft Excel"
SendKeys "Sub Test"
End Sub
Note that the SendKeys command sends the keystrokes as expected if a
worksheet is active in Microsoft Excel when you run the above
procedure.
Sub ToExcel()
' Dimension xl variable as Object type
Dim xl As Object
' Set variable xl equal to the Excel Application object
Set xl = Excel.Application
With xl
' Open workbook in Excel
' Substitute your file name in the following line
.Workbooks.Open ("c:\excel\files\test.xls")
' Insert text file that contains code
' Substitute your text file name in the following line
.ActiveWorkbook.Modules("Module1").InsertFile "c:\code.txt"
' Close file, saving changes
.ActiveWorkbook.Close True
' Quit application Excel
.Quit
End With
End Sub
Microsoft provides examples of Visual Basic procedures for illustration
only, without warranty either expressed or implied, including but not
limited to the implied warranties of merchantability and/or fitness for a
particular purpose. This Visual Basic procedure is provided 'as is' and
Microsoft does not guarantee that it can be used in all situations.
Microsoft does not support modifications of this procedure to suit customer
requirements for a particular purpose.
Sub Test()
AppActivate "Microsoft Project"
SendKeys "Sub Test"
End Sub
SendKeys
Keywords: KB126098