Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 10th, 2006, 12:21 PM
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open up Worksheet

Good Afternoon,

When I open a workbook in Excel 2003, it can't find the project, it says cannot find project when the user enables teh macros. It works fine in Excel 97.

How do I fix this?????

Kind regards,

Alan
Reply With Quote
  #2 (permalink)  
Old February 10th, 2006, 12:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You'll have a missing VBA project reference (probably!).

Go to the VBE open up the references dialog box (Tolls -> References...). There will be a series of checked items. If the problem is as I suspect then at least one of them will say "MISSING: ...". Uncheck the missing items and recheck the similarly named items from the list of unchecked items below. Hit ok and you should be good to go.

Maccas

Reply With Quote
  #3 (permalink)  
Old February 10th, 2006, 12:53 PM
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the 2 missing references are Microsofy Office 8.0 Library and Outlook 98

How do i get these? They were not in the list of available references
Reply With Quote
  #4 (permalink)  
Old February 10th, 2006, 01:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Is there not a Microsoft Office 11.0 Object Library and a Microsoft Outlook 11.0 Object Library (assumes you're using Office 2003 - change the number for a diff version of Office)?

Failing that you could look for the libraries by pressing the Browse... button and looking for the DLL files in "C:\Program Files\Common Files\Microsoft Shared\OFFICE11".

Failing that you could rewrite the code to implement late binding rather than early binding - they you don't need references.

Maccas

Reply With Quote
  #5 (permalink)  
Old February 13th, 2006, 01:52 PM
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The worksheet has the Office 11 Object library. How would I go about re-writing the code to implement late binding as I assume this would be an issue for all users using office 2003 in our company

Any help is greatly appreciated
Reply With Quote
  #6 (permalink)  
Old February 13th, 2006, 02:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Alan,

If everyone in the office is using Office 2003 then it will be far easier to just update the references to the OFFICE 11.0 libraries and release a new version of the file. This means you wan't have to recode.

If you want to implement late binding then the best way to demonstrate how to do it is with a quick example. The basic rules here are: remove all the references to the external libraries, rewrite the declarations of all external library generated objects to declare them as Object, rewrite the initial object creation lines from
Code:
Set MyObj = New ExtLib.NewObj
to
Code:
Set MyObj = CreateObject("ExtLib.NewObj")
& get rid of any user-friendly constants and replace them with the underlying numbers.

The following bit of code demonstrates two subroutines which demonstrate Early and Late binding to open Outlook from Excel and create a new message. I've written this on the fly and not debugged so it comes with a health warning but it should be close enough.

Code:
Sub EarlyBinding(msgTo As String, msgSubj As String, msgBody As String)

Dim objOutlook As Outlook.Application
Dim objExplorer As Outlook.Explorer
Dim objNs As Outlook.Namespace
Dim objMsg As Outlook.MailItem

    Set objOutlook = New Outlook.Application

    Set objExplorer = OlApp.ActiveExplorer
    If TypeName(objExplorer) = "Nothing" Then
        Set objNs = OlApp.GetNamespace("MAPI")
        objNs.Logon
    End If

    Set objMsg = objOutlook.CreateItem(olMailItem)
    objMsg.to = msgTo
    objMsg.Subject = msgSubj

    If Len(msgBdy) > 0 Then
        If HTMLFmt = False Then
            objMsg.body = msgBdy
        Else
            objMsg.HTMLBody = msgBdy
        End If
    End If

End Sub

Sub LateBinding(msgTo As String, msgSubj As String, msgBody As String)

Dim objOutlook As Object
Dim objExplorer As Object
Dim objNs As Object
Dim objMsg As Object

    Set objOutlook = CreateObject("Outlook.application")

    Set objExplorer = OlApp.ActiveExplorer
    If TypeName(objExplorer) = "Nothing" Then
        Set objNs = OlApp.GetNamespace("MAPI")
        objNs.Logon
    End If

    Set objMsg = objOutlook.CreateItem(0) 'Const olMailItem = 0
    objMsg.to = msgTo
    objMsg.Subject = msgSubj

    If Len(msgBdy) > 0 Then
        If HTMLFmt = False Then
            objMsg.body = msgBdy
        Else
            objMsg.HTMLBody = msgBdy
        End If
    End If

End Sub
Hope this helps,
Maccas

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh worksheet on open paul20091968 Excel VBA 0 May 10th, 2006 07:53 AM
finding a worksheet ozPATT Excel VBA 4 November 16th, 2005 10:54 AM
Send Worksheet alannoble26 Excel VBA 3 November 2nd, 2005 01:04 PM
Setting Worksheet name marcusfromsweden XSLT 0 September 19th, 2005 11:50 AM
how to name worksheet by Month yylee Excel VBA 2 April 10th, 2004 01:01 PM



All times are GMT -4. The time now is 08:35 PM.


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