Excel Programming in VB

  • Thread starter Thread starter ms newsgrp
  • Start date Start date
M

ms newsgrp

I want to program Excel in VB to open an existing Excel file and edit some
custom cells so new updated data for those cells are entered.

Can some help me with some suggestions or codes?

THanks
 
I think I'd start by recording a macro when I did it manually in Excel.

Then the next question: Do you really mean VB or VBA?
 
If by VB you mean the language Visual Basic and not the macro language of
Excel:

Dim xlapp as Object
set xlapp.CreateObject("Excel.Application")
xlapp.workbooks.Open Filename:="C:\MyFolder\myfile.xls"
xlapp.activesheet.Range("B9") = Activesheet.Range("B9") + 1
xlapp.ActiveWorkbook.Close Savechanges:=True
xlapp.quit
set xlapp = nothing
 
I left one reference not fully qualified. this can cause problems in
automating Excel:

Dim xlapp as Object
set xlapp.CreateObject("Excel.Application")
xlapp.workbooks.Open Filename:="C:\MyFolder\myfile.xls"
xlapp.activesheet.Range("B9") = xlApp.Activesheet.Range("B9") + 1
xlapp.ActiveWorkbook.Close Savechanges:=True
xlapp.quit
set xlapp = nothing
 
Back
Top