I have an excel workbook open and I want a .bat file to open a workbook within that same instance of excel. How do I do it? In other words, an excel workbook is already open in one instance of excel and I want to open another workbook with a .bat file script, but I do not want to create another instance of excel. Both workbooks should be open in the same instance of excel.
Here is what I am doing now, which doesn't work:
Excel workbook 1 is already open (manually), instance 1 of excel (excel.exe) is already open (manually). At some point later in time my .bat file starts running via Task Scheduler. My .bat file code looks like this:
REM open excel workbook
"C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" "Y:\somepath\somefilename.xlsm"
EXIT
...and instance 2 of excel.exe is created with "somefilename" open in it, which is wrong.
I need just one instance of excel.exe and both files/workbooks open in that one instance and I have to open the second file with a .bat file (for reasons that are frustrating, but necessary). No other languages, just batch please. Thanks!
MC ND's comment on my original question is correct:
start "" "Y:\somepath\somefilename.xlsm"
...works perfectly.
Related
I downloaded a sharepoint list as an .iqy file and used it in a Excel workbook. But, now when ever I open any Excel workbook it tries to open that file. To try and fix the issues I've:
-Deleted the .iqy file, now Excel just gives me the prompt it can't find the file.
-Removed the connection from the original workbook, but every new workbook still gives me an error looking for it.
-In the Trust Center, set Excel to not open untrusted .iqy files, still not working.
The connection to the iqy file does not appear in any new or old workbooks, and isn't in my recent connections. Also weirdly, it's trying three times to open the file (I have to click "OK" on three separate dialog boxes about the file missing).
Any ideas how to stop excel from trying to open this file every time?
Managed to fix it after stumbling through all the option in Excel. It had nothing to do with the connection. Somehow, the file was added to the "Add-In" list, so I had to remove it as an Add-In. I'll leave this question up for posterity.
I want to create a batch script that will take a .csv file that is tagged with a time stamp in the name open it, then open a specific macro-enabled Excel file (which will always be the same) and then run the macro in the 2nd workbook effective for the first workbook only.
So example:
BATCH:
for %%f in (PATH\*.csv) do ("C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE" "%%f")
I have this line to account for the changing time stamp
then the batch continues:
call PATH\Macro.xlsm
The CMD seems to stall after the first part and will not call the second file.
If I can have this open both files, can the macro run for all open workbooks rather than just the one it's built in via batch?
Any help would be appreciated as I am very new to this.
I am running a macro from an excel workbook on my local machine, and at the end of it the macro copies a set of data and pastes it in a log that is in a separate workbook. I can get it working fine when the log is on my local machine, but I am having trouble getting it to copy data to the log when the workbook is stored on the company sharepoint server. I have both files open in excel (with edit permissions on the sharepoint based file), but when I try to open the workbook it fails. Trying to diagnose the problem I even had the macro spit out a list of all the open excel files at the moment and it does not seem to list the sharepoint baesd file (despite it obviously being open at the moment). Any ideas on how I can access this file? I don't necessarily need it to open the file on its own, I am more than happy to go into sharepoint manually and open the file, I just can't get the data to copy across for some reason. Any help that could be provided would be most appreciated, thanks in advance!
The line of code causing the problem is:
Set logbook = Application.Workbooks("Log")
Where the file name is Log.xlsx and that file is open in excel at the time the macro is running.
The error I get is:
Run-time error '9': Subscript out of range
I have around 10 different excel files. For each file, I have a process saved in notepad
Every day i need to open each file, copy - paste the code from notepad to VB-excel & run the code
Is there any way I can kind of do this in batch file
Something like
Open File1
Run code of File1.
Save File 1
Repeat the same for File 2
Pls help
You should store your macro in a "Personal Workbook" described here.
The macros you store there load together with the Excel application and will be available to all workbooks you open.
In addition to the "Personal Workbook", I may even suggest automating that personal sub to open the workbooks automatically?
This could also potentially just point to a folder and For Each Workbook in definedSelectedWindowsPath
call subToAutomate()
similar to this
BIG thanks to Mr. Newman, he has certainly saved my back from a few sleepless coding problems.
Does anyone know what registry keys need to be modified in order to open macro enabled excel files in a separate instance of Excel (ie: separate windows)?
I followed the instructions on the following pages Microsoft How-To (if you want to open *.xlsx files in separate instances of excel)
and relation between registry folders and file extensions. The 'Microsoft How-To' link worked nicely and did exactly what it was supposed to do. However, I need xlsm files to open in separate windows and for the xlsx files to continue to open the default way (all in the same window/excel-instance).
I thought if i modified the Excel.SheetMacroEnabled.12\shell\open data (similar to what is described in the first link) the *.xlsm files would then always open in a new window each time.
Instead of this working successfully, now when I try to open an *.xlsm file, a blank excel window comes up with no workbook in it (after this failed attempt I imported the original settigs back so everything was restored).
Figure: I believe one of the folders shown in the image below has the key which needs to be changed in order to open excel macro files in separate windows.
You also need to delete the command REG_MULTI_SZ (the one with the seemingly gibberish-cryptographic value). Backup it in case it goes wrong!
Then, the XLSM files will open in a separate Excel program (notice the brief splash screen, which only appears when a new instance of Excel is created).
But be careful! In my tests, the order in which you open the file types make a big difference!
For example, if there is an Excel instance with a XLSM file open, and you open a XLSX file, it will try to reuse the existing Excel instance, because the registry associated to Excel.Sheet.12 tells it to do it no matter the file type already open. Only XLSM files opened after an existing Excel instance is running will create its own instance of Excel.
I will search for a workaround, but I think this is enough for you to start the tests in your computer.