Condividi tramite

VB6 Cannot Create Excel Object With Excel 2013

Anonimo
2014-05-29T15:09:05+00:00

is there any solutions??

Dim ExcelApp ``As Excel.Application

Set ExcelApp = CreateObject(``"excel.application"``)   ---> errore caricamento DLL!!! 

nei riferimenti del progetto c'è ovviamente Excel 15.0 Object library

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento

Risposta accettata dall'autore della domanda

Anonimo
2014-05-29T15:41:44+00:00

is there any solutions??

Dim ExcelApp ``As Excel.Application

Set ExcelApp = CreateObject(``"excel.application"``)   ---> errore caricamento DLL!!! 

nei riferimenti del progetto c'è ovviamente Excel 15.0 Object library

Capito poco.

Se utilizzi quel modo di istanziare un oggetto Excel, avere i riferimenti non ti serve a nulla, se non ad aiutarti nel caso tu non conosca le librerie e i relativi oggetti di Excel. Il codice qui sotto non da errore:

Public Sub m()

    Dim objExcel As Object

    Dim objWorkbook As Object

    Dim objWorksheet As Object

On Error GoTo RigaErrore

    Set objExcel = CreateObject("Excel.Application")

    Set objWorkbook = objExcel.Workbooks.Open("C:\NomeCartella\tuoFile.xlsx")

    Set objWorksheet = objWorkbook.Worksheets("Foglio1")

    objExcel.Visible = True

    With objWorksheet

        .Range("A1").Value = "Ciao ciao"

    End With

RigaChiusura:

    If Not objExcel Is Nothing Then

        objExcel.Quit

        Set objExcel = Nothing

    End If

    If Not objWorksheet Is Nothing Then

        Set objWorksheet = Nothing

    End If

    If Not objWorkbook Is Nothing Then

        Set objWorkbook = Nothing

    End If

    Exit Sub

RigaErrore:

    MsgBox Err.Number & vbNewLine & Err.Description

    Resume RigaChiusura

End Sub

La parte in grassetto *punta* ad un determinato file ed è da modificare in base al tuo contesto. La parte in corsivo *scrive* nella cella A1 del Foglio1.

Vedi anche qui per non incorrere in errori ricorsivi:

La risposta è stata utile?

0 commenti Nessun commento

0 risposte aggiuntive

Ordina per: Più utili