connectivity with exl and vb6.0

connectivity with exl and vb6.0

Page 1 of 1

2 Replies - 2099 Views - Last Post: 05 July 2008 - 10:46 AM Rate Topic: -----

#1 Raaz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 02-July 08

connectivity with exl and vb6.0

Post icon  Posted 02 July 2008 - 03:29 AM

connectivity with exl and vb6.0
Is This A Good Question/Topic? 1

Replies To: connectivity with exl and vb6.0

#2 Peter3076  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-July 08

Re: connectivity with exl and vb6.0

Posted 05 July 2008 - 09:21 AM

Hi Raaz,
Why using VB6 if you can VB2008 Express Edition free of Microsoft. Oke, that does not answer the question.

First you have to My Progject, right mouse button, Properties. Go to tab References and scroll down, if nessary. Check Excel. The result is Imported Namespaces: Excel.
Save the properties.

Oke, the code. First for VB 2008 and VB.NET
Public Sub ExcelConnection(ByVal strBestand As String)
variables
Dim Xcel as Excel.Application
Dim XcelBook as Excel.Workbook
Dim XcelSheet as Excel.Worksheet

program
On Error Resume Next
Xcel = CType(GetObject(, "Excel.Application"), Excel.Application)
If Err.Number = 0 Then
'Excel is actief
Err.Clear()
Else
'Start Excel
Err.Clear()
Xcel = CType(CreateObject("Excel.Application"), Excel.Application)
End If

'Open your File (strBestand is File)
XcelBook = CType(Xcel.Workbooks.Open(strBestand), Excel.Workbook)
XcelSheet = CType(Xcel.Workbooks(1), Excel.Worksheet)

'Make Excel with worksheet visible
Xcel.Application.Visible = True
End Sub 'Excel Connection

For VBA for Autocad it is different:
Sub ExcelConnection(Optional ByVal strBestand As String)
Dim appExcel As Excel.Application
Dim Rekenblad As Workbook
Dim Tabblad As Worksheet

On Error Resume Next
Set appExcel = GetObject(, "Excel.Application")
If Err Then
Err.Clear
Set appExcel = CreateObject("Excel.Application")
End If

appExcel.Visible = False
If strBestand = "" Then
Set Rekenblad = appExcel.Workbooks.Add
Else
Set Rekenblad = appExcel.Workbooks.Open(Bestand)
End If

appExcel.ScreenUpdating = True
Set Tabblad = Rekenblad.Worksheets.Item(1)
End Sub
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: connectivity with exl and vb6.0

Posted 05 July 2008 - 10:46 AM

@Peter3076: Just so you know, we have a policy here at Dream.In.Code to not just hand out code because someone asked for it. We require that they show some effort and show what they've tried before even thinking about showing code samples.

Thanks :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1