doubts with set method

hi everybody!

First of all, I'm sorry about my bad english, I'm trying learn it.

I'm not shure about the next point:

Learning VB languare for solidworks I have see that everybody uses the next way to create customized objects

Dim swApp                   As Object
Dim swmodel                 As Object



    

    Set swApp = CreateObject("SldWorks.Application")
    Set swmodel = swApp.ActiveDoc

That way runs ok but I have received a code with the next text

    Dim swApp As SldWorks.SldWorks
    Dim SelMgr As SldWorks.SelectionMgr
      
    Set swApp = CreateObject("SldWorks.Application")

    Set SelMgr = swmodel.SelectionManager

the last code don't compile some times. My cuestion is if the two codes are good ones and, if both of thems are right, what differences are between them.

I know that it's a basic mistake but I'm a beginner in that things

thanks

SolidworksApi macros