Results 1 to 2 of 2

Thread: MSProject and Excel question. Broken loopage!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Florida
    Posts
    12

    Question MSProject and Excel question. Broken loopage!

    I'm trying to open a folder of mpp files in sequence, copy some data, paste it in an Excel sheet and fully automate the whole procedure. Here it is so far.
    VB Code:
    1. Dim temp As Object
    2.     Dim path As String
    3.     Dim currfile As String
    4.     Dim Path1 As String
    5.     Dim xl3 As Object
    6.     Dim Temp1 As String
    7.     Dim appXL As Object
    8.     currfile = Dir("\\filesvr\department\pe\sch_control\IMSApr\*.mpp")
    9.     path = "\\filesvr\department\pe\sch_control\IMSApr\"
    10.     Path1 = "\\filesvr4\department\pe\sch_control\downloads\beth\Update_Template.xls"
    11.    
    12.     Do While currfile <> ""
    13.         Set temp = GetObject(path & currfile)
    14.         WindowNewWindow Projects:=currfile, ShowDialog:=False
    15.         '***********************
    16.         chDir ("\\P989-filesvr4\department\pe\sch_control\IMSApr\")
    17.         Temp1 = ActiveWindow
    18.         Parent.WindowActivate (Temp1)
    19.         OutlineShowAllTasks
    20.         ViewApply Name:=".SLRS Export for Update Sheet"
    21.         SelectTaskColumn Column:="ID", Additional:=19, Extend:=True
    22.         EditCopy
    23.         Set xl3 = GetObject(Path1)
    Then the excel sheet opens and the auto_open calls this macro. (The 3 macros in the midst are just formatting and populating some fields, nothing major)
    VB Code:
    1. Dim mon As String
    2. mon = Format(Now, "mmmm_yy")
    3. Dim tempxl As String
    4. Dim path As String
    5. Application.ScreenUpdating = False
    6. path = "\\filesvr\department\pe\sch_control\Downloads\Beth\Originals\"
    7.     Range("A17").Select
    8.     ActiveSheet.Paste
    9.     If Range("E18").Text <> "" Then
    10.         Columns("A:A").Select
    11.         Selection.Delete Shift:=xlToLeft
    12.         Macro2
    13.         Macro3
    14.         Macro6
    15.         tempxl = Range("E18").Text
    16.         Range("A11").Select
    17.         ActiveWorkbook.SaveAs path & tempxl & "_" & mon & "_Update_", _
    18.             FileFormat:=xlNormal
    19.     End If
    That part works fine and saves it correctly. This is the ending of the macro code in Project
    VB Code:
    1. xl3.Parent.Windows(1).Close
    2.         FileClose pjDoNotSave
    3.         '************************
    4.         currfile = Dir
    5.     Loop
    6.  
    7.     MsgBox "Status Sheets completed."
    8. End Sub
    It finishes the last portion and closes the open Project file without saving but will not loop, it just ends. I'm pretty sure it has to do with the possiblity that the macro running in Excel takes longer to complete and is running at the same time as the macro in Project. It's hard to control one office application from another. Is it possible to make this loop work or am I trying in vain? Any help offered would be appreciated.

    ~QueenB

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: MSProject and Excel question. Broken loopage!

    i think what you are trying to do is fine.

    what you would be better doing, is using a single app..e.g. Excel to do all of the work for you.

    instead of passing control between open apps the way you are doing.

    so put all of your code into Excel/Access and alter your routine to do all of the work without worrying about which app is doing what code.

    hope that makes sense.

    [EDIT] forgot to add, i think the reason it is not looping is because you are closing the controlling app?
    if you fail to plan, you plan to fail

Posting Permissions

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



Click Here to Expand Forum to Full Width