Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » OfficeAutomation - Update Requests
OfficeAutomation - Update Requests [message #34738] Fri, 09 December 2011 10:32 Go to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hello Koldo,

I have 2 modifications I want you insert in the OfficeAutomation version.

The first one is about the bad process killing: EXCEL remains in memory even if my executable is closed.
So I use a little process killer function. Do not forget to include tlhelp32.h

#include <Core/Core.h>
#include <tlhelp32.h>

using namespace Upp;

#include <Functions4U/Functions4U.h>
#include <OfficeAutomation/OfficeAutomation.h>

BOOL KillProcessByName(char *szProcessToKill)
{
	HANDLE hProcessSnap;
	HANDLE hProcess;
	PROCESSENTRY32 pe32;
	DWORD dwPriorityClass;

	hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);  // Takes a snapshot of all the processes

	if(hProcessSnap == INVALID_HANDLE_VALUE){
		return( FALSE );
	}

	pe32.dwSize = sizeof(PROCESSENTRY32);

	if(!Process32First(hProcessSnap, &pe32)){
		CloseHandle(hProcessSnap);
		return( FALSE );
	}

	do{
		if(!strcmp(pe32.szExeFile,szProcessToKill)){    //  checks if process at current position has the name of to be killed app
			hProcess = OpenProcess(PROCESS_TERMINATE,0, pe32.th32ProcessID);  // gets handle to process
			TerminateProcess(hProcess,0);   // Terminate process by handle
			CloseHandle(hProcess);  // close the handle
		}
	}while(Process32Next(hProcessSnap,&pe32));  // gets next member of snapshot

	CloseHandle(hProcessSnap);  // closes the snapshot handle
	return( TRUE );
}


CONSOLE_APP_MAIN
{
	
	try
	{
	// TEST XLS
		
		OfficeSheet sheet;
			
		bool openAvailable = sheet.IsAvailable("Open");
		bool microsoftAvailable = sheet.IsAvailable("Microsoft");
		
		if(!openAvailable && !microsoftAvailable)
		{
			throw Exc("MS Office n'est pas pret, le programme ne peut pas lire le fichier Excel!!");	
		}
		
		if (openAvailable) 
		{
			sheet.Init("Open");
		}
		else if (microsoftAvailable) 
		{
			sheet.Init("Microsoft");
		}
			
		String ficXLS = ConfigFile("test.xls");
		
		if (!sheet.OpenSheet(ficXLS, false)) 
		{
			sheet.AddSheet(true);
			
			if(sheet.InsertTab("My new tab"))
				sheet.SetValue(3, 21, "Hello");
			
			sheet.SaveAs(ficXLS, "xls");
			/*sheet.Quit();*/
			//sheet.End();  -> HOW DO I USE THIS ????
			sheet.Quit();
			
// BUG le processus EXCEL n'est pas déchargé totalement du mémoire!!!

			// PromptOK(AsString(LocalProcess("EXCEL").IsRunning()));  -> DOES NOT WORK AS I WANT SO I USE ANOTHER FUNCTION
			
			KillProcessByName("EXCEL.EXE");				
		}
		else
		{
			Cout() << "test.xls already exists!!";
		}

	}
	catch(Exc &e)
	{
		Cout() << e;	
	}

}



The second one concern OfficeSheet test of availability ( bool microsoftAvailable = sheet.IsAvailable("Microsoft")Wink
It shows the messages below if MS Office is not installed in the computer test. Could you remove these messages please.
index.php?t=getfile&id=3575&private=0

I compiled with the nightbuilt Version 4140 of TheIDE, do not consider these requests if corrections are yet done.

Best regards,

Lova Tahina
  • Attachment: message12.JPG
    (Size: 21.28KB, Downloaded 822 times)
Re: OfficeAutomation - Update Requests [message #34745 is a reply to message #34738] Fri, 09 December 2011 14:27 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello ratah

Thank you. I have replaced the MessageBox() calls with LOG() calls.

About killing EXCEL... OfficeAutomation began many years ago and was made in VBA Smile. Years later I moved it to C++ in U++. All this time from Visual Basic to C++ it was not possible to remove that problem.

At least only one EXCEL.exe thread is launched per program.

The problem of killing EXCEL is that we can kill other EXCEL process instead of the one created by the program.

Any solution will be acknowledged Smile.


Best regards
Iñaki
Re: OfficeAutomation - Update Requests [message #34775 is a reply to message #34745] Mon, 12 December 2011 10:51 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hello Koldo,

Thanks for the update.
I'm agree with you for the process killing. I'll do it later.

Re: OfficeAutomation - Update Requests [message #38388 is a reply to message #34738] Thu, 13 December 2012 12:39 Go to previous messageGo to next message
keltor is currently offline  keltor
Messages: 73
Registered: February 2012
Member
I have tried the OfficeAutomation demo from the Bazaar and, while it works well with Excel, it seems that LibreOffice is not supported correctly. I get a popup stating that the -Embedding option is not recognised. I am using LibreOffice 3.6. Is there a chance to fix that?
Re: OfficeAutomation - Update Requests [message #38389 is a reply to message #38388] Thu, 13 December 2012 13:37 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Keltor

I have not checked OfficeAutomation with LibreOffice for quite some time.
I will try it.


Best regards
Iñaki
Re: OfficeAutomation - Update Requests [message #38394 is a reply to message #38389] Thu, 13 December 2012 15:47 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Keltor

It seems to be a bug in LibreOffice reported just one month ago. See this post: https://bugs.freedesktop.org/show_bug.cgi?id=57203.

We will have to wait...


Best regards
Iñaki

[Updated on: Fri, 14 December 2012 08:37]

Report message to a moderator

Re: OfficeAutomation - Update Requests [message #38395 is a reply to message #34738] Thu, 13 December 2012 17:19 Go to previous messageGo to next message
keltor is currently offline  keltor
Messages: 73
Registered: February 2012
Member
Ah, makes sense. I looked for the "Embedded" string in the code and I couldn't find anything, now I understand why. Thanks for the heads up!

[Updated on: Thu, 13 December 2012 17:19]

Report message to a moderator

Re: OfficeAutomation - Update Requests [message #39034 is a reply to message #38395] Fri, 08 February 2013 12:06 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Keltor

LibreOffice 4.0
has been released and solves the problem with Automation Smile.


Best regards
Iñaki
Re: OfficeAutomation - Update Requests [message #39078 is a reply to message #34738] Wed, 13 February 2013 11:46 Go to previous message
keltor is currently offline  keltor
Messages: 73
Registered: February 2012
Member
Thank you Koldo! Smile
Previous Topic: OpenCL
Next Topic: Themes / Theme resets to host default when Autohide taskbar done
Goto Forum:
  


Current Time: Thu Mar 28 13:40:23 CET 2024

Total time taken to generate the page: 0.01721 seconds