get the vid of last saved vocabulary
The vocabulary object that you pass to taxonomy_vocabulary_save() will automatically be populated with the new vid, so you don't need to reload the vocabulary after you've saved it.

This code will work fine:

$vocabulary = new stdClass();
$vocabulary-&gt;name = 'Currencies';
$vocabulary-&gt;machine_name = 'currencies';
taxonomy_vocabulary_save($vocabulary);

variable_set('currencies_vid', $vocabulary-&gt;vid);