How to Split Microsoft Dynamics NAV Object files

This is nothing fancy just a little easy trick to split an object file should you be using some kind of Source
Code Control or just want to compare a few objects.

  1. Create a text file called “_split.vbs” on your local system in an empty folder. The name doesn’t matter and I use the “_” in front just for sorting reasons as you will see later.
  2. Copy the code found below into the text file and save it. (You can also download the file form here).
  3. Export objects to a txt file from the object designer in the same folder. Call it “_Export.txt”. The name doesn’t matter and again the “_” is just for sorting reasons.
  4. Open the folder in Windows Explorer and drag and drop the “_Export.txt” file and drop it on top of the “_split.vbs” file

Hopefully you will now see your objects being saved as individual files in your folder (and the 2 original files are at the top) and not somewhere in between the rest of them :-)

I have not tested on all versions, but it should work from Navision Financials 1.00 and up to Microsoft Dynamics NAV 2013R2 unless I am very wrong.

Enjoy.

February 28, 2014: I placed an updated VBS file on my OneDrive. The updated version makes the entire filename including the extension in uppercase. Microsoft and others use this, so I am just following up with an update on this little tool.

Option ExplicitConst ForReading = 1
Const sObject = “OBJECT ”
Const sTable = “Table ”
Const sForm = “Form ”
Const sReport = “Report ”
Const sDataport = “Dataport ”
Const sCodeunit = “Codeunit ”
Const sXMLPort = “XMLport ”
Const sMenuSuite = “MenuSuite ”
Const sPage = “Page ”
Const sQuery = “Query “Dim FileSystemObject
Dim SourceStream
Dim TargetStream
Dim TargetFileName
Dim Argument
Dim SourceLine
Dim TargetLineSet FileSystemObject = WScript.CreateObject(”Scripting.FileSystemObject”)For Each Argument in WScript.Arguments
If FileSystemObject.FileExists(Argument) Then
Set SourceStream = FileSystemObject.OpenTextFile(Argument, ForReading)
Do While Not SourceStream.AtEndOfStream
SourceLine = SourceStream.ReadLine
TargetLine = SourceLine
If Left(SourceLine, Len(sObject)) = sObject Then
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sObject))
Select Case True
Case Left(SourceLine, Len(sTable)) = sTable:
TargetFileName = UCase(Left(sTable, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sTable))
Case Left(SourceLine, Len(sForm)) = sForm:
TargetFileName = UCase(Left(sForm, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sForm))
Case Left(SourceLine, Len(sReport)) = sReport:
TargetFileName = UCase(Left(sReport, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sReport))
Case Left(SourceLine, Len(sDataport)) = sDataport:
TargetFileName = UCase(Left(sDataport, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sDataport))
Case Left(SourceLine, Len(sCodeunit)) = sCodeunit:
TargetFileName = UCase(Left(sCodeunit, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sCodeunit))
Case Left(SourceLine, Len(sXMLPort)) = sXMLPort:
TargetFileName = UCase(Left(sXMLPort, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sXMLPort))
Case Left(SourceLine, Len(sMenuSuite)) = sMenuSuite:
TargetFileName = UCase(Left(sMenuSuite, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sMenuSuite))
Case Left(SourceLine, Len(sPage)) = sPage:
TargetFileName = UCase(Left(sPage, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sPage))
Case Left(SourceLine, Len(sQuery)) = sQuery:
TargetFileName = UCase(Left(sQuery, 3))
SourceLine = Right(SourceLine, Len(SourceLine) - Len(sQuery))
Case Else
MsgBox “Invalid object type (” & TargetLine & “).”, vbOKOnly or vbCritical
WScript.Quit
End Select
TargetFileName = TargetFileName & Left(SourceLine, InStr(SourceLine, ” “) - 1)
If IsObject(TargetStream) Then
TargetStream.Close
Set TargetStream = Nothing
End If
Set TargetStream = FileSystemObject.CreateTextFile(FileSystemObject.GetParentFolderName(Argument) & “\” & TargetFileName & “.txt”, True)
End If
TargetStream.Write TargetLine & vbCrLf
Loop
SourceStream.Close
Set SourceStream = Nothing
End If
Next

Set FileSystemObject = Nothing

4 Responses to “How to Split Microsoft Dynamics NAV Object files”

  1. Danny Says:

    Unfortunately this code does not work (syntax error).
    Could you please check formatting in Wordpress (e.g. “ and \”)?
    Maybe you could publish the code directly in a download file…
    Thanks so far!

  2. Nuno Says:

    Navision object splitter, it splits and joins the files

  3. sorenk Says:

    Hi Danny, There is a link in the text to download the file or you can check out my public folder where I will store all my things as I release them.
    https://skydrive.live.com/redir?resid=C56B8DE0E403F8CA%21106
    /Soren

  4. sorenk Says:

    Hi Nuno, Yes you can do that too, but this is just a very fast way of splitting them with out having to do very much.
    Putting them back together is easy. “copy *.txt Object.txt” will do that job for you.

Leave a Reply

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word