Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2005, 07:32 AM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel and Missing MS Form Components...

Hi,

I have developed an Excel application with some VB Forms included. Some of the Controls on these forms are taken from specific References (namely MS Windows Common Controls-2 6.0), which i know will not be available on all users machines when distributing the application and will cause errors on running.

To overcome this i can check References.IsBroken on some machines, but others won't allow me to access the .VBProject (for security reasons) so this solution isn't universal. So what i am trying to do is Workbooks.Open a "pre-installation" .xls, with a single form and control on it. If a warning message is generated i know the Control is not available on this machine, but instead of displaying the warning message i want to capture this fact and have my controlling code record the shortfall in the users PC configuration. Any ideas?

Apologies for the long-winded nature of this one,

Thanks in advance,

Steve
 
Old July 21st, 2005, 07:51 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can I suggest that you use your is broken code to identify if there is any broken references (funny that) but then if any are found you could use the following snippit to write a text file for each reference not found on the first run. Each time the code is run using the workbook_open, the code would find the file and not continue because of some form of error trapping...


Sub mdl_CheckForFile()
On Error GoTo myError
    With Application.FileSearch
        .LookIn = "c:\"
        .Filename = "ReferenceDoesntExists.txt"
        If .Execute() > 0 Then
            MsgBox "There were " & .FoundFiles.Count & _
                " file(s) found."
        Else
            MsgBox "There were no files found."
        End If
    End With
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile("C:\ReferenceDoesntExists.txt", True)
    a.Close

End Sub


 
Old July 21st, 2005, 08:10 AM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nearly....

....but if i take my application to some users PCs and try a pre-installation test of ThisWorkbook.VBProject.References.IsBroken (or similar!) - it fails with "Unable to access VBProject", which is a security option for Excel (defaults to secure for 2003), so i want to avoid this means of testing for installed References by simply having my installation checking code do a Workbooks.Open a simple workbook with nothing but a set of forms with an example of each of the required controls. Now when i manually open this simple workbook on a machine without the References installed i get a warning that some objects could not be loaded (which is correct) and now i want this warning to be captured if i try to open this workbook through code (i.e. Workbooks.Open "Test.xls" with a CaptureWarningAsError option would be nice!).

Clear as mud now?!

Steve







Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the format of MS Excel Cells from MS Access hewstone999 Access VBA 0 March 7th, 2008 07:19 AM
Compare Two MS access db file and find missing rec lawsoncobol Reporting Services 0 August 3rd, 2006 04:14 AM
Exporting data from MS Excel sheet to Ms Access ajindal General .NET 1 January 17th, 2005 03:00 AM
Embedding Office Web Components form JSP sunildath_019 JSP Basics 0 March 17th, 2004 06:11 AM
Embedding Office Web Components form JSP sunildath_019 Pro JSP 0 March 17th, 2004 06:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.