Hi all,
I posted a thread a few days ago regarding opening a .CSV file and then running a macro saved in an external workbook on the CSV.
The problem was that opening the .CSV using VB.NET was causing some dates which calculations need to be carried out on to be read incorrectly.
I'm now using Process.start to open excel, then creating a wait time using a message box to wait for excel to load the .csv, before clicking continue, at this point, I need the macro to run on the .CSV file, however the macro is running on the .XLSB file that contains the macro!
How can I make the macro run on the .CSV instead?
I'm totally stuck so any help would be much appreciated!
Br,
Callum
I posted a thread a few days ago regarding opening a .CSV file and then running a macro saved in an external workbook on the CSV.
The problem was that opening the .CSV using VB.NET was causing some dates which calculations need to be carried out on to be read incorrectly.
I'm now using Process.start to open excel, then creating a wait time using a message box to wait for excel to load the .csv, before clicking continue, at this point, I need the macro to run on the .CSV file, however the macro is running on the .XLSB file that contains the macro!
How can I make the macro run on the .CSV instead?
Code:
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oBooks = oExcel.Workbooks
'opens the file already selected, the location for which is currently in textbox2
Process.Start("EXCEL.exe", """" & TextBox2.Text & """")
'Run the macros.
MsgBox("Please press OK once Excel has loaded")
' Run the macros.
oExcel.Run("'C:\Omron Healthcare\Omron Health Management Software\System\OmronReport.xlsb'!OmronBP")
'Clean-up: Close the workbook and quit Excel.
oBook.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks = Nothing
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
Br,
Callum