+ Reply to Thread
Results 1 to 3 of 3

Problem with Late Binding MS Project Library

  1. #1
    Registered User
    Join Date
    08-31-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Problem with Late Binding MS Project Library

    I am one of the authors and current owner of a spreadsheet template which is used by many staff members in my organization. This particular workbook has a great deal going on, but one item in particular plagues me. At one point, someone wrote a macro to import resources and hours from an MS Project file into a worksheet in the tool. From time to time I have tried to resolve the issue with using different versions of MS Project with the tool. I though I had implemented late binding some time ago, but continued to see the problem. Just recently I realized that it was because I neglected to deselect the library in References before publishing the new template. So I gleefully assumed that I had finally resolved the issue, did a little testing, and deployed it.

    Wrong! Now, with the MS Project library deselected I get a compile error (variable not defined). The "variable" it complains about is the pjDoNotSave option that's part of the Project file close and exit command.

    I can only assume that once again I've missed something. So here's the important part of the code and hopefully someone will spot what I'm doing wrong before I pull out my hair or perhaps suggest a more clever way to close an MS Project file without saving from Excel. Thanks in advance for any help.

    ____________________________________________

    Sub AddResourcesFromProject()

    ' This Macro adds each resource name and hours for each week from mpp file into the "MPP Estimate" sheet's "Original Estimated Labor" section
    ' It also set the project's start date in spreadsheet as the project start date in mpp and updates total project weeks . To be able to run this macro, mpp file should be in the same directory as the spreadsheet file.

    Const DateColNum = 12

    Dim Proj As Object
    Dim Res As Object
    Dim TSV As Object
    Dim TotalWeeks As Object
    Dim i As Long
    Dim j As Integer
    Dim ResColNum As Integer
    Dim xlRange As Excel.Range
    Dim ProjectName As String
    Dim FileToOpen As Boolean
    Dim d As Date
    Dim projStartDate As Date
    Dim k As Integer
    Dim importRoles As Integer

    Set Proj = CreateObject("MSProject.Application")

    ProjectName = InputBox("Enter Project File Name: ")

    If Not FileExists(ActiveWorkbook.Path & "\\" & ProjectName) Then
    Application.ScreenUpdating = True
    MsgBox ("Cannot find file " & ProjectName & " in the folder " & ActiveWorkbook.Path & ". MS Project File must be in the same folder as the Project Workbook.")
    Exit Sub
    End If

    Proj.FileOpen (ActiveWorkbook.Path & "\\" & ProjectName)

    ...

    Proj.FileCloseEx pjDoNotSave
    Set Proj = Nothing
    AppActivate "Microsoft Excel"

    ' Turn on all screen updates
    Application.ScreenUpdating = True

    End Sub

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Problem with Late Binding MS Project Library

    Leave the reference while developing code. For the variables, either define them and assign the value or just use the value. With the object set in Tools > References, in the Immediate Window, type a question mark and then the variable, and press Enter key to see the value. Or, press F1 with cursor in or near the variable. Uncheck reference prior to compiling and saving for production.
    e.g.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-31-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Problem with Late Binding MS Project Library

    That does it! Thanks for your quick reply.
    Now if I can just figure out how to mark this one as solved, I'm all set.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Seeking knowledge on Early Binding, Late Binding
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2013, 10:45 PM
  2. SAP Late Binding Problem
    By msnews.microsoft.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2006, 02:40 PM
  3. [SOLVED] VB Extensibility library and "late binding"
    By Dennis in forum Excel General
    Replies: 0
    Last Post: 03-30-2005, 06:06 PM
  4. Late Binding examples of binding excel application
    By HeatherO in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-17-2005, 01:06 PM
  5. Late binding to .XLA library??
    By Lee S in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-04-2005, 05:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1