Let's take a look at an example. Let's say there's a Counter program you've developed and you want to reuse this. Go to Project > Export
You may export Devices, POUs or Modules. Select the Counter (PRG)
Then in your new project, you would go to Project > Import
Note the above has the POUs Project Settings selected. If you're trying to import the program, select Application in the Devices. This will then show the Counter (prg):
Note Counter program has been imported into the Application.
However, it is better practice that the user created programs, function blocks and functions (altogether are POUs) reside within the POUs and not under Devices. You may drag the Counter into the POUs NewProject container:
Now the Counter PRG is in the POUs. If you try to do a Build (F11) the message window will indicate our variable CounterPLC hasn't been declared. That's because in the original project, this was in the Global Variable List. Since you may want to use this variable in other programs within the application, we can add a Global Variable List by right-clicking on Application and adding a Global Variable List (GVL):
And then add CounterPLC as a double integer:
During the export, the GVL could've been selected but as it wasn't, this causes an error after importing. The message window after you do a Build will point any errors out and allow you to track these down to resolve. One error can cause multiple errors in the message window. You can double-click on the error and that will take you to the area in the program that's causing the error.
Now back to the program. We have it but it's not set to run on the Application. To add this, under Task Configuration, right-click on MainTask (your task may have a different name or you can add a lower priority task to the Task Configuration) Add Object > Program call...
In the Add Program call window, select the ...
From the Input Assistant, you can select the POU:
Press F11 to Build and you should have no errors and then you're ready to go onload, which will download the application to the device.