ProjectFile.getDefaultCalendar is mismatch with ProjectProperties.getDefaultCalendarName - mpxj

I am using MPXJ 7.8.1 to read MS Project File(.mpp). I changed the Project Calendar to "24 Hours" as following:
ProjectProperties.getDefaultCalendarName returns the correct calendar name "24 Hours".
But the ProjectFile.getDefaultCalendar returns the incorrect calendar "Standard".
...
UniversalProjectReader reader = new UniversalProjectReader()
ProjectFile projectFile = reader.read(stream)
ProjectProperties projectProperties = projectFile.getProjectProperties()
"projectProperties.getDefaultCalendarName = " + projectProperties.getDefaultCalendarName() + ", projectFile.getDefaultCalendar = " + projectFile.getDefaultCalendar().getName()
Output: projectProperties.getDefaultCalendarName = 24 Hours, projectFile.getDefaultCalendar = Standard
Is there a way to get the correct calendar?

I've tried this locally with MPXJ 7.9.1 and the functionality seems to work as expected. If you are still having issues, can you open an issue on GitHub and attach an MPP file which demonstrates the problem - thanks!

I recently dug it more and found out that this is caused by the software "Project Plan 365" I use. In the file generated by it, the value of the default calendar is incorrect, which makes it unrecognizable when read with MPXJ. Files generated using MS Project do not have this problem.

Related

Uploading Excel file using VBA to SharePoint

Im struggling to resolve an upload problem direct from excel to sharepoint. I have the right permissions and can upload no problem when hardcoding the URL. Issue I have is all the SharePoint URL's are by Project Number and Description for example:
https://teamzzz.sharepoint.com/sites/Projects/NL001%20%20TEST/10.%20Dispatch
The project is called NL001 in this case. Another example of a URL could be:
https://teamzzz.sharepoint.com/sites/Projects/ZNP001%20%20ANOTHERTEST/10.%20Dispatch
Basically at the point of attempting to upload using my Add in I know the first part of the PATH:
https://teamzzz.sharepoint.com/sites/Projects/
The project id I can find from a cell reference:
NL001
The last part of the URL will always be the same as in:
10.%20Dispatch
My problem is the description after NL001 i.e. "%20%20TEST" (see below):
https://teamzzz.sharepoint.com/sites/Projects/NL001%20%20TEST/10.%20Dispatch
Is there anyway I can use some form of wildcard in the URL for example:
https://teamcde.sharepoint.com/sites/Projects/NL001*/10.%20Dispatch
OR
https://teamcde.sharepoint.com/sites/Projects/NL001%/10.%20Dispatch
The above 2 example dont work but was demonstrating the example I require. Here is my code thus far:
Public Sub CommandButton39_Click()
ProjectFileName = Range("B2").Value
SharePointBasePath = "https://teamcde.sharepoint.com/sites/Projects/"
SharePointEndPath = "10.%20Dispatch/"
ActiveWorkbook.SaveAs Filename:=SharePointBasePath & ThisFile & ".xlsm" & SharePointEndPath
End Sub
Is is possible to utilise a wildcard as the description is not known at time of upload.
Thankyou

VBA - "FORMAT" function isn't recongnised on 1 computer

I've coded something in VBA to help my co-workers and it's working on 8 computers but on this one computer, everytime I try to start the code, it gives me an error.
Sorry I'm translating from French into English but the error is:
Compilation error:
Project or library isn't found
The actual code is:
' ============================================
' === TRAITEMENT DES PRODUITS DU GROUPE 10 ===
' ========== FOURNISSEURS STANDARDS ==========
' ============================================
Case 10
Select Case var_Prix
Case Is < 25
Range(COLLISTE & var_Ligne).Value = Format(99999, "#,####0.0000")
Range(COLPRIX2 & var_Ligne).Value = Format(var_Prix / (0.5 - TRANSPORT), "#,####0.0000")
Range(COLPRIX3 & var_Ligne).Value = Format(var_Prix / (0.52 - TRANSPORT), "#,####0.0000")
Range(COLPRIX4 & var_Ligne).Value = Format(var_Prix / (0.55 - TRANSPORT), "#,####0.0000")
Range(COLPRIX5 & var_Ligne).Value = Format(var_Prix / (0.6 - TRANSPORT), "#,####0.0000")
<the code continues>
and it has Format highlighted. Seems like the "Format library" isn't installed but I've tried Google and apparently "Format" is installed with windows or office.
As JKP asked, are there any references marked as "missing"? A missing Ref can cause unpredictable behaviour in other referenced libraries.
As a temporary solution, try forcing the reference by putting VBA. before the format, like
= VBA.Format(99999, "#,####0.0000")
This normally works.
Had this issue recently. Cause was 'something' had disabled the "Analysis Toolpack - VBA" Add-in.
so just had this issue. The solution we found was to add Microsoft Scripting Runtime and Microsoft Word 16.0 Object Library back to the References - VBA Project selection.
Not sure which one actually fixed it. But both made the rest of my file work.

notes url (notes://) sometimes does not create icon on workspace

I'm maintaining an application which sends out E-Mails with a notes url link like this:
noteshref = "notes://" & serverName.Common & "/" & docToLink.Parentdatabase.Replicaid & "/" & viewUNID & "/" & docToLink.Universalid
the viewUNID is calculated thusly:
Dim viewUNID As String
Set nc = db.Createnotecollection(False)
nc.Selectviews=True
nc.Selectionformula={#isMember("Vtousdocuments";#explode($Title;"|"))}
nc.Buildcollection
If nc.Count > 0 Then
viewID = nc.Getfirstnoteid
Dim note As NotesDocument
Set note = db.Getdocumentbyid(viewID)
viewUNID=note.Universalid
Delete note
Else
viewUNID="0"
End If
Delete nc
I've looked at the documentation for the NotesURL:
https://www-10.lotus.com/ldd/dominowiki.nsf/dx/notes-urls
I've seen demonstrations via a remote session when the database icon on the workspace is not created when opening the link. The Document gets opened, but no bananas on the 'create a Workspace icon on the database' behaviour.
I haven't been able to reproduce this on my machine, and I've also noted that, contrary to the documentation, the server 'hint' is not considered - one of the possible replicas is pulled out of thin air and recreated on the workspace.
Am I missing anything? Are there perhaps some combinations of the notesurl that do not create icons on the workspace (i.e. a naming convention for the server)? Or could it be something more obscure, like corrupted desktop.ndks?
I have used this URL format in few places and it has always worked and it opens the right server. One thing I do differently is use /0/ instead of the view UNID "/" & viewUNID & "/". This would directly open the document if its present in the db and its also faster.
But your solution also should work, if the issue is specific for few users you should delete the cache/desktop and try.

Compile error can't find project or library

I'm not familiar with VB6 , I would like to compile an existing project in a new environment (which mean new desktop) , so do I missed some development tools or references to run the code below ? Because when I running the project it pointed to (Date) .
ExcelSheet.Cells(2, 1).Value = "Printed As At " & ls_now
If optCurrent.Value = True Then
ExcelSheet.Cells(4, 1).Value = "Year : " & Year(Date)
Else
ExcelSheet.Cells(4, 1).Value = "Year : " & cboYear.Text
End If
Please Help , thousand thanks
This is usually a side effect of a missing project reference. Hit the Project->References menu:
Look for anything that is marked as 'MISSING'. Those are the things that need to be installed/registered on your development machine. Once you do so, you'll have to restart VB to reload your project.
If Date is VB6's Date function it needs () after it. In all basics except VB.NET, functions must have brackets, and subs musn't. There is also a Date statement that sets the date. That what yours is being interpreted as, but it makes no sense inside another functions parameters.
You could have pressed F1 and learnt this.

How do I set up a COM Server interface with Excel?

Versions
Excel 2003Windows XP SimaPro 7.3.0 Developer Version Using a Work computer but was made administrator on this machine Libraries referenced in Excel/VBA: Visual Basic for Applications; Microsoft Excel 11.0 Object Library; OLE Automation; Microsoft Office 11.0 Object Library; Microsoft Forms 2.0 Object Library; COM+ 1.0 Admin Type Library; COM MakeCab 1.0 Type Library; COM+ Services Type Library; SimaPro Library Me: Beginner
What I'm trying to do
I am using a program called SimaPro that stores databases of "Life Cycle Analysis" information. The program has built in COM interface functionality. The program states that it does, indeed support Excel/VBA (but it doesn't specify versions).
I am trying to connect this program and/or COM server to excel so that I can interact with the information through excel.
What I've done
I've done the procedure they list:
-Open SimaPro
-Register COM Server
-Then I pasted the below code into VBA and tried to run it. This code is the sample code provided by the software company, I edited only the SP.Server, SP.Alias, SP.Login, and SP.OpenProject fields (below is as edited).
What Happened
Run-time Error: '-2147418113 (8000ffff)':
Automation Error
Catastrophic Failure
Question(s)
-Is the server name right? I've been reading a little on COM servers and I don't know if the way I put it in is in the right "form"
-Could it have something to do with certain registered/unregistered DLLs? I've worked with the company's IT people, and software programmers. None of them were very familiar with COM but one person suggested the DLLs might be the issue.
Thanks for your help!!
Here is the code that I'm inputting:
Sub CreateProcess()
Dim SP As SimaProServer
Dim PC As Process
Dim PC2 As Process
Dim PL As ProcessLine
Dim Param As ParamLine
Dim Subs As Substance
Set SP = New SimaProServer
SP.Server = "Local Server"
SP.Alias = "C:\Documents and Settings\All Users\Documents\SimaPro\Database\"
SP.Database = "Professional"
SP.OpenDatabase
SP.Login "", ""
SP.OpenProject "PROJECT", ""
' Not project's actual name, not allowed to state name of project
SP.CreateSubstance "Air", Subs
Subs.CASNumber = "4-5-13"
Subs.Name = "Some substance"
Subs.DefaultUnit = "kg"
Subs.Update
SP.CreateProcess ptMaterial, PC
Set PL = PC.AddLine(ppProduct, -1)
PL.ObjectName = "Steel 2"
PL.UnitName = "kg"
PL.Amount = "2"
PL.Comment.Add ("My new created process")
PL.CategoryPath = "Chemicals\inorganic"
PC.Update
' create second material process Case
SP.CreateProcess ptMaterial, PC2
Set PL = PC2.AddLine(ppProducts, 0)
PL.ObjectName = "Case 2"
PL.UnitName = "kg"
PL.Amount = "10"
Set Param = PC2.AddParamLine(ptInputParameter, -1)
Param.Name = "A"
Param.Value = "2,3"
' add input from Steel
Set PL = PC2.AddLine(ppMaterialsFuels, -1)
' input from steel
PL.SetProduct "Introduction to SimaPro 7", ptMaterial, "Steel 2"
PL.Amount = "8"
PL.UnitName = "kg"
Set PL = PC2.AddLine(ppAirborneEmissions, -1)
' input from steel
PL.SetSubstance "Some substance", ""
PL.Amount = "A+1"
PL.UnitName = "kg"
PC2.Update
SP.Logout
SP.CloseDatabase
Set SP = Nothing
End Sub
Given that this was more than one year ago. I'm assuming you got this working. If you haven't yet, I might know what the root cause might be.
I used to get the same error and from your changes for server, alias and login, I was able to make it run. One thing that is different is that you have changed the name of the project to "Project" from "Introduction to SimaPro 7". I honestly have zero (not being humble here) VBA knowledge. So, I'm speculating that there is no project names "Project" to open. I'm not sure if VBA would create a project automatically, if it can't find it. You can either try creating a project named "Project" or just rename it back. I am interested to see if that worked.
Automation Error usually means that there was a problem within the COM library you try to use. As it is a run-time error, it could be something very stupid, as missing parameter or wrong path or access rights. In my opinion, it also means that the library is not very well designed.
As you are not the author of the library you do not have many options. You can try to contact the vendor to get more documentation. You can also pray that the designer thought about logging - check the event log; if you are lucky you may find something interesting there.
Answering your first question, if you referenced the library and the code compiles - that means that you did everything right there.

Resources