2 Replies Latest reply: Oct 7, 2011 1:34 PM by Kiran Rokkam RSS

    Problem to run macro with a button

    Sushil Kumar

      Hi all,

       

      I am using a macro to select a date range. i have created a button to run the macro but whenever i press the button, it opens up the macro editor window...

       

      the macro is :

       

       

      sub DataBetweenSelectedDate 'Used with the Variables , it filter the reports for two selected dates

      set FD = ActiveDocument.Variables("From date") '' variable for Initial date

      FrmDtt=(FD.GetContent.String)

      FrmDate=">=" & month(FrmDtt) & "/" & Day(FrmDtt) & "/" & year(FrmDtt)

      set TD = ActiveDocument.Variables("To date")

      ToDtt=(TD.GetContent.String)

      ToDate="<=" & month(ToDtt) & "/" & Day(ToDtt) & "/" & year(ToDtt)

      if FrmDtt>ToDtt then

      msgbox "Start Date Should be less than End Date"

      else

      ActiveDocument.Fields("T_DAY_DATE").Select FrmDate   &   ToDate

      end if

      end sub

       

       

      Please help to resolve this issue..

       

       

      Thanks

      Sushil