How to convert TIF to JPG using VBA ExportRasterFile?

I wrote a VBA code to convert TIF to JPG, but it does not work. I get run time error 5 when I run my code. Can someone help me? I'm using Microstation v8i. My code is below one.

RasterManager.ExportRasterFile sourcefilename:=fpath & "\" & fname, destinationfilename:=fpath & "\" & fso.GetBaseName(fname) & ".jpg", NewFormatSpecifier:=RasterManager.RasterFormats.Find("JPEG(J)")