Excell - Aprire Excell






Dim a As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.WorkSheet
Dim Valore As Integer

'apri excel

Set a = New Excel.Application

'apre il file

Set wb = a.WorkBooks.Open("c:\file.xls")

'seleziona il foglio

Set ws = wb.Worksheets(1)

'estrae il valore dalla cella D3

valore = ws.Cells(3, 4)

'chiude tutto

wb.Close
a.Quit


***********************************************************

Dim exApp As Excel.Application
Dim exWb As Excel.Workbook
Dim exWs As Excel.Worksheet
Dim numRighe As Integer
Dim indRiga As Integer

'apre excel

Set exApp = New Excel.Application
exApp.Visible = True

'apre il file xls

strPerc = "C:\...\prova.xls"
Set exWb = exApp.Workbooks.Open(strPerc)

'seleziona il foglio 1

Set exWs = exWb.Worksheets(1)

'conta il numero di righe

numRighe = exWs.Rows.CurrentRegion.Count

For indRiga = 2 To numRighe
'leggo il contenuto delle celle

Next indRiga

'salva e chiude file

exWb.Save
exWb.Close
'esce da excel

exApp.Application.Quit
'cancella le variabili oggetto

Set exApp = Nothing
Set exWb = Nothing
Set exWs = Nothing










( excellaprireexcell.html )- by Paolo Puglisi - Modifica del 17/12/2023