开发者

How Do I Programmatically Open and Close a Specific Microsoft PowerPoint Mobile File/Presentation?

开发者 https://www.devze.com 2023-02-05 23:49 出处:网络
I am helping a friend with a project/experiment. The task is to repetitively open and close various applications hundreds of times on a PDA and to record the battery’s consumption. Then the experimen

I am helping a friend with a project/experiment. The task is to repetitively open and close various applications hundreds of times on a PDA and to record the battery’s consumption. Then the experiment is repeated, but for this next time anti-virus software has been installed and is presumably running in the background; here again, the applications are opened and closed and the battery consumption is recorded. The PDA is using Windows Mobile 6. The task of opening and closing the apps has been automated via a program written in the .NET Framework Compact Ed开发者_开发问答ition 3.5. The program uses the System.Diagnostics.Process component to start and close applications. One of the requirements is to open files in the Office Mobile application suite.

So, Word Mobile opens some DOC file and Excel Mobile opens something. This is accomplished by passing arguments via the Process StartInfo.Arguments. It works for Word and Excel, but it does not work for PowerPoint; to be sure, PowerPoint opens, but does not appear to react to arguments passed via StartInfo.Arguments (even when the arguments are purposefully incorrect, e.g.: you are not prompted with a warning if you send a file path that does not exist).

Here are the questions:

  1. Can PowerPoint Mobile open a presentation by passing arguments via the Process StartInfo.Arguments?
  2. If not, what other options exist such that PowerPoint Mobile can be controlled in this respect (specifically, so it can be opened then shut down repetitively)?
  3. This third is not really a question, but just suggestive of a solution/question: Had I encountered problems on a desktop computer forcing me to create a workaround, I would have written a small VBA program in the specific PowerPoint file I want to open, which would load the file (PowerPoint Mobile’s purpose appears only to execute the presentation opposed to what one would see if they open the desktop version of PPT) and then shut itself down because in that case I can still perform two functions from the controlling program, i.e.: open the app then wait until it closes. Additionally I will add that I know very little about Microsoft Office Mobile and PDAs.
  4. Here are a few more observations. I thought perhaps I could execute a short-cut, but I am informed that that did not work. And one last note, even if there exists such a workaround like that, the GetProcesses() method is unavailable in the Compact Framework. Can I send operating system commands on a PDA? For example, on a desktop computer I can access the executing processes via “tasklist”. Okay, I’m done.


  1. Since you've tried passing arguments in the same way you did for Word Mobile and Excel Mobile and it's failing with PowerPoint mobile, the logical inference is that no, command-line parameters are not supported. This assumes you've done the code (which you've not shown) correctly, but since calling Process.Start is pretty straightforward and you've got it working for other app, I assume you've got it right here too.
  2. None of the Pocket Office apps are documented in any way. We do know that they don't have any automation interfaces or APIs, so if a command line argument doesn't do anything, you're pretty much out of luck unless you want to hack in SendMessage calls to simulate clicking the menu items and entering the file name. If opening a file is absolutely required, that's probably the route I'd try next.
  3. Pocket Office has no VBA/scripting support, so this is not an option on the device.
  4. A shorcut is going to be identical to calling the app with a command-line. Both effectively do the same thing. You can get the process list via the toolhelp APIs, but it's not going to give you any control over those processes (other than to kill them, which you can already do with the Process instance returned by Process.Start()


I believe that the smart device framework used to include two different ways of achieving question 2 but they were removed when the compact framework got the ability to call "System.Diagnostics.Process.Start" in one if its later releases.

However the compact framework version of Process.Start requires the two parameters (exe, filename) you mention above and cannot directly be called using just a file name. Even though the compact framework version was not as useful as the smart device framework code it was enough to lead to its removal from the main project.

The older version of the smart device framework allowed a call directly to the file name and used pinvoke to fire up the file checking the registry for the associated program.

OpenNETCF.WinAPI.Core.ShellExecute("\\My Documents\\Test.pxl", "");

or I believe an alternative way was to call..

OpenNETCF.Diagnostics.Process.Start("\My Documents\Test.pxl")

The second method was still available in version 1.4 of which the source code is still available. You can download them from OpenNetCF (at the bottom of the page) and extract the code which they were using or even compile the dlls up yourself and call them from your project.

Hope this helps in some way

0

精彩评论

暂无评论...
验证码 换一张
取 消