I am trying to create a code that runs when the workbook is opened. I try with Auto_open and workbook_open (inside ThisWorkbook object) But I have a problem with both of them. The problem is that the code needs info from the workbook that I am opening As you can see in this peace of code:
Sub Auto_Open()
Dim fileNam As String
Dim text As String
Dim answer As String
Dim question As String
Dim quesPos As Integer
MsgBox "add-in start"
'On Error GoTo GetOut
fileNam = ThisWorkbook.FullName
jsonFile = Replace(jsonFile, "xls", "survey.descriptor.json")
Open jsonFile For Input As #2
pos = 1
ThisWorkbook.Sheets("Result").Select
'The code gives the error here
As the excel file is not already opened it gives an error while getting the name of the file. How can I make to exec the code when it opens but after it is opened?
ThisWorkbook.FullName
instead. – Tim Williams