The functions you want are methods of the Variant Manager Application object.
IsVariantView: Checks if the main application is variant (or function) view.
GenerateVariantView: Generates a Variant View; ie puts the application into variant mode. You specify which variant to use for the view.
ResetView: Puts the application in the master view mode.
Look in the help under Application Object in the Variant Manager Automation Reference.