Developing a macro code for creating a workpiece based on final product

Hi everyone, my aim is basically to creating a workpiece from any final product using visual basic language in solidworks macro but I am unsure how to do it. I am planning to use the highest and lowest point of the final product and from there create a workpiece. Its something like before you machine the workpiece, you need a workpiece with the dimentions based on the highest and lowest point of the final product. I have attached a file of a sample final product as well as the screenshot of the product and the workpiece. Appreciate all the help I can get

SolidworksApi/macros