connectivity with exl and vb6.0
connectivity with exl and vb6.0connectivity with exl and vb6.0
Page 1 of 1
2 Replies - 1849 Views - Last Post: 05 July 2008 - 10:46 AM
Replies To: connectivity with exl and vb6.0
#2
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
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
#3
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
Thanks
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|