Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,474 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,582 people online right now. Registration is fast and FREE... Join Now!




connectivity with exl and vb6.0

 
Reply to this topicStart new topic

connectivity with exl and vb6.0, connectivity with exl and vb6.0

Raaz
2 Jul, 2008 - 02:29 AM
Post #1

New D.I.C Head
*

Joined: 2 Jul, 2008
Posts: 1

connectivity with exl and vb6.0
User is offlineProfile CardPM
+Quote Post

Peter3076
RE: Connectivity With Exl And Vb6.0
5 Jul, 2008 - 08:21 AM
Post #2

New D.I.C Head
*

Joined: 5 Jul, 2008
Posts: 4


My Contributions
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

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Connectivity With Exl And Vb6.0
5 Jul, 2008 - 09:46 AM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,993



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
@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 smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:03PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month