.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 18th, 2003, 07:50 PM
Optical Optical is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 1 Optical User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help Starting a Process from asp.net

Hello, <br><br>I am trying to Automate MSAccess in order to generate snapshot reports online. I have based my code on MSDN KB article# 317114. <br>http://support.microsoft.com/default.aspx?scid=kb;en-us;317114 <br><br>Below is a code sample. <br><br><br>private void OpenAccess() <br>{ <br> string sDBPath = "C:\WebRptTest_01.mdb"; <br> string sAccPath = "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE"; <br> string sCmdLine = """" + sDBPath + """"; <br> Access.Application oAccess = null; <br> Process p = null; <br><br> ProcessStartInfo startInfo = new ProcessStartInfo(); <br> startInfo.FileName = sAccPath; <br> startInfo.Arguments = sCmdLine; <br> startInfo.WindowStyle = ProcessWindowStyle.Maximized; <br><br> p = Process.Start(startInfo); <br> p.WaitForInputIdle(60000); //max 1 minute wait for idle input state <br><br> // Move focus back to this form. This ensures that Access <br> // registers itself in the ROT: <br> //this.Activate(); <br><br> // Pause before trying to get Application object: <br> System.Threading.Thread.Sleep(1000); <br><br> oAccess = (Access.Application) Marshal.BindToMoniker(sDBPath); <br>} <br><br><br>My problem is that every time I get to the line that uses "Marshal.BindToMoniker" another instance of Access is started instead of grabbing the running instance. I have narrowed the cause down to one of 2 problems: <br><br>1) (Most probable) I don't believe that the command line arguments are being executed when the process is started. That being the case, Access is starting up without opening a file. Thus when the Marshal.BindToMoniker line is called, it begins a new instance using the sDBPath. Can anyone tell me why the command line arguments would not be executed? Am I starting the process wrong? <br><br><br>2) It is also possible that Access is not registering itself in the ROT. Office products do not register themselfs in the ROT until they lose focus. In the KB code, they use WinForms and call this.Activate() in order for office to lose focus. How can I do this when using asp.net? I have no window to move the focus too. <br><br><br>Any help is greatly appreciated! <br><br>----mike

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Help Starting a Process from asp.net


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT