Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to create new .xls file in c drive and open,save,update with vb6
Posted

1 solution

Found this on Google[^]

VB
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim var As Variant

Set xlApp = New Excel.Application

Set wb = xlApp.Workbooks.Open("PATH TO YOUR EXCEL FILE")

Set ws = wb.Worksheets("Sheet1") 'Specify your worksheet name
var = ws.Range("A1").Value

'or
var = ws.Cells(1, 1).Value

ws.Cells(1, 1).Value = "Sample Text"
wb.Close
xlApp.Save
xlApp.Quit

Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing


Just add a reference Microsoft Excel Object Library
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900