insert row to Excel spreadseet from VB

K

Ken Snell

You must use Automation to open the EXCEL file and to write to the specific
"row" of cells.

This is some generic code:

Dim xlsApp As Object, xlsWB As Object, xlsWS As Object, xlsRng As Object
Set xlsApp = CreateObject("Excel.Application")
Set xlsWB = xlsApp.Workbooks.Open("C:\FolderName\FileName.xls", , True)
Set xlsWS = xlsWB.Worksheets("WorkSheetName")
Set xlsRng = xlsWS.Range("A1")
xlsRng.Value = VariableName
Set xlsRng = Nothing
Set xlsWS = Nothing
xlsWB.Close True
Set xlsWB = Nothing
xlsApp.Quit
Set xlsApp = Nothing
 
A

Alex

Thanks, Ken.
-----Original Message-----
You must use Automation to open the EXCEL file and to write to the specific
"row" of cells.

This is some generic code:

Dim xlsApp As Object, xlsWB As Object, xlsWS As Object, xlsRng As Object
Set xlsApp = CreateObject("Excel.Application")
Set xlsWB = xlsApp.Workbooks.Open
("C:\FolderName\FileName.xls", , True)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top