Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sushil353
Master II
Master II

Problem to run macro with a button

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

2 Replies
m_woolf
Master II
Master II

When it opens the macro editor, does it highlight a specific line?

Can you post your qvw for examination?

Not applicable

You can msgbox at different lines to find which line the error is triggered. I think something is wrong with else part of your code. Check adding msgbox right after else.