I have a set of 6 text files, and I want my script to randomly select one of them, so I generate a random number between 1 and 6, then append the file address with that number and the extension ".txt," and then then use COM Object Get to retrieve the contents of said file, and then paste it's content.
But it keeps giving me an error saying "Bad Extension for File," And I cannot for the life of me figure out what's causing the problem! Extensions are visible in Explorer, and I've quintuple checked to make sure it's typed correctly.
Here's my code:
Code: Select all
#j::
Random, BodyNumber, 1,6
Msgbox, %BodyNumber% ;For Debug
SelectedRandomBody := "S:\Recruiting\Advertising\Automation\Bodies\Body" . BodyNumber . ".txt"
Msgbox,,Random Body Variable, %SelectedRandomBody% ;For Debug
oDoc := ComObjGet(SelectedRandomBody).Range.FormattedText.Copy
Send, ^v
return