Jump to content

Excel interface


PeterPan9720

Recommended Posts

Please somebody can help me in a little issue ?

I'm trying to have an excel interface in order to write some drawing blocks attribute excration.

Here below code:

 

Dim NUOVA_ISTANZA As Object
Dim WRKB As Workbook                                                    ' Attribuzione della variabile "Cartella di lavoro Excel"
Dim WRKS As Worksheet                                                   ' Attribuzione della variabile "Foglio di lavoro"

On Error GoTo MESSAGGIO_ERRORE

Set NUOVA_ISTANZA = GetObject(, "Excel.Application")                    ' Attribusce alla variabile "NUOVA_ISTANZA" l'applicazione Excel: se Excel non è aricatot restituisec un errore
Set WRKB = NUOVA_ISTANZA.Workbooks.Add                                  ' Attribuisce alla variabile WRKB la cartella di lavoro Excel corrente
Set WRKS = NUOVA_ISTANZA.ActiveSheet

Now, I got an error message on WRKB As Workbook instruction "User defined type not defined".

If I continue without variable dim, later when I'm trying to set an excel sheet formatting as border and other cells formatting

With WRKS.Columns(2).Resize(, 3)                                                            ' Bordo destro e sinistro colonne coordinate
   .Borders(xlEdgeLeft).LineStyle = xlContinuous
   .Borders(xlEdgeRight).LineStyle = xlContinuous
   .Borders(xlInsideVertical).LineStyle = xlContinuous
End With

 

I got an error "Application-defined or object-defined error"

 

Please help me

Link to comment
Share on other sites

  • 4 months later...

Hello!

You need firstly to set a excel reference, so you will get manipulate what you want.

Let's try help with a litle example:

tuto-1.jpg.15912c23f109aaa216b233fc5590095b.jpg

tuto-2.jpg.c86d359cfa803fde2432ea512e0f33ef.jpg

 

This error "Application-defined or object-defined error" is typical ausency of the object.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...