|
-
Aug 29th, 2006, 06:49 AM
#1
Thread Starter
Junior Member
Excel file path help!
This is my code below:
Code:
Function searchdata()
Dim objBooks As Excel.Workbooks
Dim objsheets As Excel.Sheets
Dim objsheet As Excel.Worksheet
Dim range As Excel.Range
'create a new instance of Excel and start a new workbook
objApp = New Excel.Application
objBooks = objApp.Workbooks
objBook = objBooks.Add
objsheets = objBook.Worksheets
objsheet = objsheets(1)
'get the range where the starting cell has the address
'm_sStartingCell and its dimensions are m_iNumRows x m_iNumCols
range = objsheet.Range("Q2", "AC5001")
a = 0
b = 1
r = 2 'row
Do
Do
If aclient(a) <> "" And aport(b) <> "" Then
Do
If aclient(a) = objsheet.Range("ABr").Value And portnum(b) = objsheet.Range("Qr").Value Then
bytes(a, b) = ((bytes(a, b) + objsheet.Range("Zr").Value))
Else
r += 1
End If
Loop Until objsheet.Range("ABr").Value = "null"
End If
b += 1
r = 2
Loop Until b = 6
a += 1
b = 1
r = 2
Loop Until a = 10
End Function
I dont want to create a new spreadsheet. I want to open an existing spreadsheet. Where and how do i do this?
-
Aug 29th, 2006, 07:50 AM
#2
Re: Excel file path help!
change this line...
objBook = objBooks.Add
to this line...
objBook = objBooks.Open("C:\MyFile.xls")
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|