Flixbus is the dominant bus company in much of Europe now, and they list a direct bus from Venice to Ljubljana taking about 4-5 hours at a cost of the equivalent of 24-34 USD per ticket (they use the model of prices rising as the buses fill).
It's been a long time since I travelled but there's also a car-share service that should still be working BlaBlaCar. Just checking now, if I wanted to leave right now there's a car with two free spots leaving in an hour for about half the above amount each, and taking only 3 hours.
Looking at trains, you'd either have to transfer in Villach (Austria) or Trieste. Longer, more expensive, more complicated. The only possible advantage is taking in the scenery and the general train experience, or of course if you want to stop and see Trieste, which I've never been to but should be a quite worthwhile experience.
Edit: For the above I used Ljubljana as reference, but I don't know what exactly you want to see in Slovenia. If it's the mountains, you're going to have to go through the capital anyhow, but if it's like the seaside, that's right next to Trieste (which should honestly by all rights be part of Slovenia
) or there's even a ferry right from Venice to Piran, though a quick check shows it only seems to go once a week on Saturday and only during the high season.