Open and Closing Excel from InTouch

Join Date
Mar 2016
Location
Reading
Posts
2
I'm still relatively new to InTouch so please excuse my ignorance.

What I'm trying to do is print an excel sheet. When I looked up the manual it seems that the right approach is
1. Open Excel File
2. Send a print instruction to excel
3. Close the Excel file.

To do this I'm using the following code
_______________________________________________________________
{Open Excel}
StartApp "C:\Program Files\Microsoft Office\Office 12\Excel.exe C:\Drum...csv;

{Print}
SendKeys "^(p)";
SendKeys "{ENTER}";

{Close Excel}
App_Title = InfoAppActive("EXCEL")
App_Active = InfoAppActive(App_Title);
WWControl(App_Title, "Close");
_______________________________________________________________

The issue that I'm hitting is that the excel file is not closing.

During my testing to try to fix this issue I found that:-
1. When I run the script once the App_Title is blank and the App_Active is No
2. If I run the script twice it closes the first excel spread sheet when the script is run the second time. (And App_Title changes to "Microsoft Excel..." and AppActive is set to YES)

My suspicion from this is that Excel is busy doing stuff when the close instruction is sent and therefore it just ignores it.

Does this sound possible/likely to be the issue?

Is there a way to add a delay or pause into an InTouch script so that it will wait a few seconds to allow excel to open fully before it tries to close it again?

Is there another way to achieve this same result that may not encounter this issue?

Any help would be appreciated.

Thanks,
Craig
 
I did this several years ago. The issue I had was with the title of the excel sheet. To get around this issue I used the SendKeys command to exit excel.

SendKeys "%f"; 'Alt F - File
SendKeys "x"; ' X - exit

Regards,
 
Thank you for your quick responses.

I had a chance to play today and found that although what gclshortt suggested worked (I think with the addition of () - i.e. SendKeys "%(f)" ) this function only closes the worksheet in Microsoft Excel not the whole program. (sorry wasn't very clear on that in my original post).

So thank you to cjd1965 for your input also turns out this is what I needed.

So the final code looks like this

______________________________________________________________
{Open Excel}
StartApp "C:\Program Files\Microsoft Office\Office 12\Excel.exe C:\Drum...csv;

{Print}
SendKeys "^(p)";
SendKeys "{ENTER}";

{Close Excel}
SendKeys "%({F4})";
_____________________________________________________________

So again thank you to both gclshortt and cjd1965 you both saved me from days of frustration and misery!!
 

Similar Topics

Hi Can anyone send me 5 or 6 graphics for a valve showing the following states for TIA Portal v15.1 wincc open opening close closing faulted...
Replies
7
Views
2,366
hello I have 7cp476 cpu why can led always open and No connection
Replies
1
Views
106
Anyone have issues with RSLinx being very slow to open. It sometimes will say "Checking Activation" at the bottom for what seems like an...
Replies
2
Views
122
Hi all Trying to remotely connect to a TIA Portal PLC. I can ping it without a problem but can't get my software to connect. I've opened port...
Replies
8
Views
310
and then when i open the windowmaker, intouch is shutdown... that's not work that's demo I have 30days demo
Replies
3
Views
142
Back
Top Bottom