How do I insert an Excel file into VB 6. I need to be able to view the file in a seperate form. I know the coding to change the forms is

Form1.Hide
Form2.Show

And I read a previous thread before on these forums that gave me the coding to load it:

Dim xlTmp As Excel.Application

Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open App.Path & "\times.xls"

Could anyone please help me to find what the solution so the Excel spreadsheet may be displayed on the form?

Recommended Answers

All 8 Replies

Bump

Could someone please help

Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim stre As String
Set xlApp = New Excel.Application

Set wb = xlApp.Workbooks.Open("C:\Documents and Settings\c5098466\My Documents\Guru\Solution Tracker\Notefix Tracker1.xls")

Set ws = wb.Worksheets("Sheet1")
'Give your worksheet name
stre = ""
For i = 1 To 10
For j = 1 To 12
stre = stre & ws.cells(i, j).Value & vbTab
'Print (ws.cells(i, j).Value)
'Do whatever u want here
Next
stre = stre & vbCrLf
Next
wb.Close
Print stre
xlApp.Quit

Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing

here how can i specify the EOF in the for loops

i have a problem can you help me? here`s my problem,can you help me how to make an inventory system..plzzzzz

Hi Markx,

Post ur own thread.
ur problem may go unnoticed if u Post in other threads.
And what is the Kind/Nature of business u want to develop the inventory..?

Regards
Veena

Regards
Veena

Hi, Guru,

u need to check if all the cell Values r blank continously and come out of the loop

Regards
Veena

hi veena..
i got how to go till the last used row..
i used

Dim ra As Excel.Range
Set rang = ws.UsedRange

' and then i used
ra.Rows.Count
ra.columns.count


that solved my purpose

hi veena..
i got how to go till the last used row..
i used

Dim ra As Excel.Range
Set rang = ws.UsedRange

' and then i used
ra.Rows.Count
ra.columns.count


that solved my purpose

Hi Guru,

Good to know that u cud solve it..
and posted here so that every one can use it..

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.