02-27-2014 09:56 PM - edited 02-27-2014 09:58 PM
Hi,
I want to read data from the first worksheet of an excel workbook regardless of it's state:
1) Opened
2) Closed
...without any prompts.
Closed is the easy part because the workbook is not open.
If the work workbook is open, and you attempt to open it to obtain a reference it says something like "Workbook is already open. Opening it again will discard changes."
The question of the day: How to obtain a reference for an already opened workbook without Excel prompting? Assuming I JUST referenced the specific Excel application.
Thanks,
Aric
Solved! Go to Solution.
02-28-2014 02:00 AM
Setting DisplayAlerts to F might help - http://msdn.microsoft.com/en-us/library/office/ff839782.aspx
If it doesn't, I would suggest a Google search. What applies to other languages should also apply here. I haven't tried, but I would expect that if you call the Count property on the app's Workbooks property, you will get 0 if none exist.
02-28-2014 02:30 PM
I don't post unless I've googled! Thanks for the reply.
The DisplayAlerts will automatically select "reopen without keeping changes" but I want the "save then reopen" functionality. Or an alternative method of obtaining the workbook reference, if opened already.
02-28-2014 02:47 PM
Yes, the count method works. I just didn't know about the _Application.ActiveWorkbook functionality. Here is a working block diagram.
02-28-2014 04:04 PM - edited 02-28-2014 04:05 PM
Here is another option for checking if open/getting an open workbook reference that I have used in the past. I think this is a working version of it anyways. Admittedly, I didn't double check.
10-06-2014 01:04 PM
I'm trying to do something similar, write to an existing and open Excel file. Other excel files will be open so I need to make sure that the correct one is selected an active. Can you explain what is in your "refnum cluster in"? is it the excel reference and filename path? thanks
10-06-2014 01:37 PM
@JessicaM wrote:
I'm trying to do something similar, write to an existing and open Excel file. Other excel files will be open so I need to make sure that the correct one is selected an active. Can you explain what is in your "refnum cluster in"? is it the excel reference and filename path? thanks
abeaver's Refnum Cluster has the refnums for the Excel Application and the Excel Workbook. Nothing special.
10-08-2014 12:38 AM
Thanks. I was able to get abeaver's program to work, but I'm still missing the ability to be able to select and make a specific workbook the active one if other workbooks are also open. For instance, I want my program to open and write to a file called Text.xls. I can get the program to do this. However, if i have another workbook open, say Data.xls, I can't seem to get the program to recognize the difference between the two files. When it checks to see if the workbook is open, it's checking to see if any workbook is open, not Test.xls specifically. So, when it writes data, it writes it to whichever Excel workbook is currently active. Is there a way to get the program to check for and make a specific workbook if other workbooks are also open? thanks
10-08-2014 07:36 AM
@JessicaM wrote:
Thanks. I was able to get abeaver's program to work, but I'm still missing the ability to be able to select and make a specific workbook the active one if other workbooks are also open. For instance, I want my program to open and write to a file called Text.xls. I can get the program to do this. However, if i have another workbook open, say Data.xls, I can't seem to get the program to recognize the difference between the two files. When it checks to see if the workbook is open, it's checking to see if any workbook is open, not Test.xls specifically. So, when it writes data, it writes it to whichever Excel workbook is currently active. Is there a way to get the program to check for and make a specific workbook if other workbooks are also open? thanks
http://msdn.microsoft.com/en-us/library/office/ff835568%28v=office.14%29.aspx
convert to LabVIEW
10-08-2014 02:51 PM
@nyc_(is_out_of_here) wrote:
http://msdn.microsoft.com/en-us/library/office/ff835568%28v=office.14%29.aspx
convert to LabVIEW
I admit that I am not good with ActiveX, and am having some trouble figuring out how to convert to LV. Do you have any suggestions or examples? I have searched through most of the forums and the Excel toolkit but am coming up empty on how to select a specific workbook if a bunch of workbooks are open...