My code is a bit different than yours on line 3, which is why I might have gotten the error, however, since getting the error I created a new library, project and sub-scenarios, and then went ahead and re-built my model with the existing code that I had, and did not get the error.
I think the problem occurs when I close Visual Studio and re-open. I will let you know if I run into this problem again. Ben is helping me along as well.
If you are curious, Here was the exact code (I did not include all of the addRow lines here though).
# Initial Stocks
initialStocks = scenario(myProject, “SF Initial Stocks”, overwrite = T)
sheetName = “SF_InitialStockNonSpatial”
sheetData = datasheet(myProject, name = sheetName, scenario = “SF Initial Stocks”, optional = T, empty = T)
sheetData = addRow(sheetData, data.frame(StockTypeID = “Deadwood”, StateAttributeTypeID = “Carbon Initial Conditions: Deadwood”))
sheetData = addRow(sheetData, data.frame(StockTypeID = “Dead Root”, StateAttributeTypeID = “Carbon Initial Conditions: Dead Root”))
saveDatasheet(initialStocks, sheetData, sheetName, append = F)