Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Project Newsgroups
Project Developer
Does Application.Projects.Count have a known bug?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Ancient Brit, post: 4896051"] A follow-up to the follow-up: It seems that Projects().Activate is not the culprit - I simplified the code (kept the same project, which contains four embedded subprojects, all read-only), and the macro worked without problems. It can be run repeatedly and works exactly as expected. The core code is this: Sub testing() Dim ProjectPointer As Long, pbNames As String For ProjectPointer = 1 To Projects.Count Projects(ProjectPointer).Activate pbNames = pbNames & Projects(ProjectPointer).FullName & vbCrLf & vbCrLf Next ProjectPointer MsgBox pbNames End Sub Where the error comes in is when the name of each subproject is retrieved. I added some code to extract the name of each embedded subproject and incorporate it into the string pbNames (the numbers simply allow me to keep track of the projects): Sub testing() Dim ProjectPointer As Long, pbNames As String For ProjectPointer = 1 To Projects.Count Projects(ProjectPointer).Activate pbNames = pbNames & Projects(ProjectPointer).FullName & vbCrLf & vbCrLf i = 1 For Each SubProjectName In ActiveProject.Subprojects pbNames = pbNames & Str(ProjectPointer) & "." & Str(i) & ") " & SubProjectName.SourceProject.Name & vbCrLf i = i + 1 Next SubProjectName Next ProjectPointer MsgBox pbNames End Sub The first pass through works OK; subsequent attempts to run the macro generate the 1004 error. I can't see why requesting the subproject name should change the project count... Best, Peter [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Project Newsgroups
Project Developer
Does Application.Projects.Count have a known bug?
Top