I have a database that is opened by users with different versions of Access. The reference to MS Excel 15.0 shows up after an Office 2013 user has opened it and the database will not open in earlier versions of Access afterwards until I changed the Excel reference back to an earlier version. I have tried to change all references to Excel in the code to be late binding: - Function OpenExcel(strFileName As String)
-
Dim xl As Object
-
-
Dim WKB As New Excel.Workbook
-
-
Set xl = CreateObject("Excel.Application")
-
xl.Visible = True
-
Set WKB = xl.Workbooks.Open(strFileName)
-
Set xl = Nothing
-
Set WKB = Nothing
-
-
End Function
-
This code is just a sample. There are hundreds of references to Excel in the project. That does not seem to make any difference. Is there some way of late binding Excel so that it won't make it change the reference to Excel 15.0 or some workaround to deal with users who have 2007, 2010 and 2013? Any advice is much appreciated.
6 1018
Hi
Looking at the sample coder you still seem to be early binding as you have a variable declared as Excel.Workbook.
If you do not get a compile error then it would seem you also have reference set to the Excel object library. This will need removing. Any references to the Excel library will then cause a compile error and you can then change the variable to an Object type.
However this does impose a strict discipline requiring you to explicitly refer to the Excel application's object, properties and methods.
ie
XlApp.Cells(1,2)= "some value"
I never use early binding in Access when automation Excel.
HTH
MTB
To program Excel with Late Binding, MikeTheBike has you covered: - Remove all references to Office
- Declare your variables as Objects
Late Binding works just fine, but you'll loose Intellisense which is a drag. Another option is to split the Front End and Back End and then deploy a Front End to each of your users, so they have their own FE database that they can destroy without affecting your other users. You may already know all about splitting the database, but just in case: http://bytes.com/topic/access/insigh...ront-back-ends
The code I put in the original post was a bad example. What I'm having trouble with is calling functions that use the worksheet object, to write text to a spreadsheet. For example the following code: - Sub ChoiceReport(ByRef RS As DAO.Recordset, strWKB As String, strCaption As String)
-
'Dim wks As Worksheet
-
-
-
Dim lngRow As Long
-
Dim rrow As Integer: rrow = 3
-
Dim actionFlag As String: actionFlag = ""
-
Dim xlAPP As Object
-
Dim WKB As Object
-
Dim WKS As Object
-
-
Set xlAPP = CreateObject("Excel.Application")
-
Set WKB = xlAPP.workbooks.Open(strWKB)
-
-
-
-
-
-
Set WKS = WKB.Worksheets("ChoiceRpt")
-
-
-
writeCellText WKS, rrow - 2, 1, strCaption, actionFlag, "Center"
-
This calls the "writeCellText" function: - Sub writeCellText(w As Object, ssRow As Integer, ssCol As Integer, someText, actionFlag As String, alignment As String)
-
-
' -------------------------------------------------------
-
' Write the value into the cell - that's the easy part...
-
' -------------------------------------------------------
-
w.Cells(ssRow, ssCol) = IIf(IsNull(someText), "", someText)
It does not write any text to the spreadsheet. I think the problem is that the "writeCellText" function doesn't know what the WKS object is that is passed to it as an object. How does one get around this? Do I need to send the string name of the WKS and then set it up with the xlApp application variable? Thanks for advice.
This is working for me: - Sub ChoiceReport()
-
-
Dim rrow As Integer: rrow = 3
-
Dim actionFlag As String: actionFlag = ""
-
Dim xlAPP As Object
-
Dim WKB As Object
-
Dim WKS As Object
-
-
Set xlAPP = CreateObject("Excel.Application")
-
Set WKB = xlAPP.workbooks.Open("C:\Temp\Bytes\sampleTemp.xls")
-
Set WKS = WKB.Worksheets("ChoiceRpt")
-
-
writeCellText WKS, rrow - 2, 1, "Test Text", actionFlag, "Center"
-
-
WKB.Save
-
WKB.Close
-
End Sub
-
-
Sub writeCellText(w As Object, ssRow As Integer, ssCol As Integer, someText, actionFlag As String, alignment As String)
-
w.Cells(ssRow, ssCol) = IIf(IsNull(someText), "", someText)
-
End Sub
Are you getting an error? Also, you can get into that situation where the file is opened but not closed and then things start acting weird. Maybe close Access and attempt to rename the Excel File and try again.
JForbes, thanks for your help. That does work. Now that I am using late binding on this Access project, the spreadsheets seem to take extra long to generate. Is that to be expected?
It will take longer. The calls themselves are supposed to take about twice as long to make and depending on how busy your application is, it could start adding up.
Here is a pretty good article on what you are doing: https://support.microsoft.com/en-us/kb/245115 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Manlio Perillo |
last post by:
Hi.
I'm a new user of Python but I have noted a little problem.
Python is a very good language but it is evolving, in particular its
library is evolving.
This can be a problem when, ad example,...
|
by: j.b.messina |
last post by:
This has not yet been published by Microsoft. It will be published
within the next few weeks, mainly because I asked them to. I felt this
was information badly needed, and I think this is the...
|
by: Shadow Lynx |
last post by:
At the bottom of the default Error page that appears when Unhandled
Exceptions occur, what exactly is the difference between the "Microsoft
..Net Framework Version" and the "ASP.NET Version"?
I...
|
by: salad |
last post by:
Is it preferable to create runtimes when distributing apps or preferable
to expect the client to have valid versions of Office with Access on it.
I have an app that requires Word and Outlook. So...
|
by: Hongbo |
last post by:
Hi,
I have a web site built in ASP.Net 1.1 running on production server. It's the version 1.0.
Now I need to build the version 2.0 for this web site. The version 2.0 will be built based
on the...
|
by: Sky |
last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but
be Type, AssemblyName. Fair enough, get the reason. (Finally!).
As long as it doesn't cause tech support problems...
|
by: ev951 |
last post by:
I am not that familiar with XML or XSL and I am trying to sort application version number strings in an XML file that my team uses for application installations on our Linux servers. I have tried...
|
by: schaf |
last post by:
Hi Ng!
My application (version 1 a1) communicates with a service (version 1
s1). Now I would like to update the service and create a service
version 2 (s2). The new function calls within s2 are...
|
by: Bob Altman |
last post by:
Hi all,
I have a C++/CLI project (VS 2005) that produces a DLL that exports C bindings.
Internally, this DLL contains routines compiled with /clr.
I notice that my DLL doesn't have a version...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |