0

I'm trying to develop an excel file that contains VBA to manipulate and adjust repots that are excel files generated from SQL Server using Excel-Macro Enabled Template. The excel that contains the VBA has a List Box to shows all excel files that are open and a text box for the selected report, as shown in the attached picture. the main excel file The 1st problem I faced was to display excel report that are open in a different instance of Excel. I posted a question and I got an answer, attached link, my previous question, that solved the problem and open excel files can be shown in the List Box. The problem now is, how can I pass the name of the selected report (workbook name) to subs and functions to become the file that will be manipulated using the VBA code? I tried this way Sel_Rpt = Sheet1.TextBox1.Value and then Set Rpt = Workbooks(Sel_Rpt).Worksheets("Report"), but it didn't work.

Sami
  • 13
  • 4
  • 1
    Keep a reference to each workbook object and pass the selected reference to your subs instead of just passing the workbook name – Tim Williams Sep 10 '22 at 22:52
  • `GetObject("Filename and path")` switches to the open file (it will be registered in the ROT (Running Object Table)) or if not open opens the file. – Lundt Sep 10 '22 at 23:26
  • @TimWilliams , Could you please explain more or give details or example? thanks – Sami Sep 13 '22 at 17:44
  • You don't show any code, so it's difficult to make a useful suggestion here. – Tim Williams Sep 19 '22 at 18:54

0 Answers0