Hey all,
So I have an Excel macro that has the following:
which adds a new row (at row 2) and inserts "ABC" in cell D2.
However, I need some way to embed this code behind an Access button in VBA. I understand that you can call an Excel Macro from Access, but the Excel document is changing often and will not always have the macro attached.
So my question is: How can I open the Excel document, insert a Row at line 2 and type "ABC" in cell D2, and save and close the Excel document? ALL from Access VBA, It is not possible to have any macros saved in Excel.
My .xls file is named "importtest.xls" and the sheet where I want to do this editing is "Sheet1"
Thank you very much! Let me know if I was unclear, seems like a long question.
So I have an Excel macro that has the following:
Code:
Sub Test()
Rows(2).EntireRow.Insert
[D2] = "ABC"
End Sub
However, I need some way to embed this code behind an Access button in VBA. I understand that you can call an Excel Macro from Access, but the Excel document is changing often and will not always have the macro attached.
So my question is: How can I open the Excel document, insert a Row at line 2 and type "ABC" in cell D2, and save and close the Excel document? ALL from Access VBA, It is not possible to have any macros saved in Excel.
My .xls file is named "importtest.xls" and the sheet where I want to do this editing is "Sheet1"
Thank you very much! Let me know if I was unclear, seems like a long question.