|
-
Nov 6th, 2005, 07:20 PM
#1
Thread Starter
New Member
Help on excel
Hi,
I have written a VBA procudure in excel using Microsoft office 10.0 Object library. But I am not able to run this on other comps. since the Object library is different (11.0). I guess this is the reason for the procedure to not work. Can someone please help troubleshoot this problem. Is these a way to make this procedure compatiable across all computers irrespective of version differences?????
Thanks in advance
Siddharth
-
Nov 6th, 2005, 07:40 PM
#2
Re: Help on excel
You need to use Late Binding instead of Early Binding. Late binding does not require a reference to Excel at all allowing the use of different versions. You do need to be careful to only use properties, methods, and functions that are supported by the versions of Excel you need to support.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim oApp as Object
Dim oWB as Object
Set oApp = CreateObject("Excel.Application")
Select Case oApp.Version
Case "10.0", "11.0", "12.0"
'Valid supported version or ???
Case Else
MsgBox "Excel Version not supported!"
'Exit your application or disable features.
End Select
Set oWB = oApp.Workbooks.Open("C:\BVook1.xls")
oWB.Sheets("Sheet1").Cells(1, 1) = "Test"
oWB.Save
oWB.Close
Set oWB = Nothing
oApp.Quit
Set oApp = Nothing
End Sub
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
|