how to import basic code from LO3.5 to LO5.1.6.2

Moving from ubuntu 12.04 LTS LO3.5 to ubuntu 16.04 LTS LO5.1.6.2 Cannot find a way to get code copied into 5.1 that runs and cannot find a way to import modules.
Copied code shown below.

GlobalScope.BasicLibraries.LoadLibrary(“Tools”)
oDialog1 = LoadDialog(“Standard”, “Dialog1”) invokes below

Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
If IsMissing(oLibContainer ) then
oLibContainer = DialogLibraries
End If
oLibContainer.LoadLibrary(LibName)
oLib = oLibContainer.GetByName(Libname)
oLibDialog = oLib.GetByName(DialogName) <— gives

BASIC runtime error.
An exception occurred
Type: com.sun.star.container.NoSuchElementException
Message: .

Make a backup of the ~/.config/libreoffice/4/user/basic/ directory and then merge the file content from each ~/.config/libreoffice/3/user/basic/* file into the corresponding ~/.config/libreoffice/4/user/basic/* file including the subdirectories and files. You can probably overwrite the ~/.config/libreoffice/4/user/basic/** files if they are nearly empty except the default template frame, which should be the case if you didn’t edit macros with your new 5.1 version. But check first.