Automation Excel too slow..

I like to get some help from Excel-automation-experienced guys:
I started from article http://support.microsoft.com/kb/186122/ which shows
how to open, read some contents, close excel file in MFC.
I copied codes from article and pasted to OnInitDialog() with slight
modification. Every time I click button, it opens, reads, displays Excel
file contents in poped-up dialog, then when OK button clicked, it closes
Excel file and application. It seems works and I have two problems here(I am
using VC++6.0, win2000, excel 2000):

1. Too slow.. about 8 seconds after button clicked, 'Server Busy' message
box poped-up. It provides two button 'SwitchTo' and 'Retry'. I always need
to click 'Retry' button to proceed. What am I doing wrong here?

BOOL CMyDlg::OnInitDialog()
{
 CDialog::OnInitDialog();
     // ...............
      _Application objApp;
      _Workbook objBook;
      Workbooks objBooks;

      // Instantiate Excel and open an existing workbook.......... it takes
too long???
      objApp.CreateDispatch("Excel.Application");
      objBooks = objApp.GetWorkbooks();
      objBook = objBooks.Open("C:\\Work\\Test.xls",
                VOptional, VOptional, VOptional, VOptional,
                VOptional, VOptional, VOptional, VOptional,
                VOptional, VOptional, VOptional, VOptional);

      // read, fill, find, whatever .......

      //Close the workbook without saving changes
      //and quit Microsoft Excel.
      objBook.Close(COleVariant((short)FALSE), VOptional, VOptional);
      objApp.Quit();

2. Can I start and quit Excel application in main frame rather than in my
dialog's OnInitDialog() so that multiple parts of my program can play with
Excel file? What I have tried was make _Application objApp, _Workbook
objBook, Workbooks objBooks as global variable and the debugger is giving
errors:

       First-chance exception in Medisafe.exe (OLE32.DLL): 0xC0000005:
Access Violation.

Thanks in advance
Bob



0
bbg9507 (39)
9/11/2005 11:27:19 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
893 Views

Similar Articles

[PageSpeed] 59

>Too slow.. about 8 seconds after button clicked, 'Server Busy' message
>box poped-up. It provides two button 'SwitchTo' and 'Retry'. I always need
>to click 'Retry' button to proceed. What am I doing wrong here?

Nothing from a procedural point of view. If you need to get rid of the
dialog box or extend the time before it displays then look at
AfxOleGetMessageFilter and the class COleMessageFilter.

>Can I start and quit Excel application in main frame rather than in my
>dialog's OnInitDialog() so that multiple parts of my program can play with
>Excel file? What I have tried was make _Application objApp, _Workbook
>objBook, Workbooks objBooks as global variable and the debugger is giving
>errors

Yes no problem but even better for a global Excel is create it in your
applications InitInstance and quit it in your applications
ExitInstance. What you have is a memory access violation so you need to
figure out which COM call is giving it. There should be no problems
with cross-thread marshalling as your dialog will most probably be
created on your main thread. To test either use the thread window or
print out the value of GetCurrentThreadId() in both your main thread
and the function where you call DoModal - check they are the same.

0
rquirk1 (133)
9/12/2005 2:33:10 PM
Reply:

Similar Artilces:

Copy an Excel page
Now that I've created page one on sheet one, and I want to have five duplicate pages, how do I copy page one multiple times? Simple way is to copy and then paste, paste, paste. Do you mean page 1 of worksheet 1 of workbook 1? where page is a part of a worksheet. "Mark" <anonymous@discussions.microsoft.com> wrote in message news:04b101c398e4$1c495800$a301280a@phx.gbl... > Now that I've created page one on sheet one, and I want > to have five duplicate pages, how do I copy page one > multiple times? Hi, Right click the tab, select move or copy, check the c...

Is this possible to do in excel?
I have to excel worksheets. The first sheet has to columns that have a part number and a cost field. The second worksheet also has a part number and a cost column except that the cost column has no values in it. What I want to do is to create some sort of query or program on the second worksheet that will try to match part number of the 2nd worksheet to the first. If it finds a match, I want it to populate the cost field with the quantity that is in the 1st worksheet. Is this possible? Is so, how do you do it? Thanks, Jasper Assume... Sheet1: Part No. is in A2:A100 and Cost is in B2:...

Excel #144
How can I keep a tally in Excel by going back to the same cell and entering slash marks without deleting the previous slash marks. This is for a test and I need to keep a total of how many answered a specific question. Can someone please help me? Thank you. duoble click onto the cell (or single click and press F2) to add more slashes. you could have a function next to it to keep count. I.e if the slashes are in cell E5 in F5 enter =LEN(E5) -- greetings from New Zealand Bill Kuunders "Donna" wrote: > How can I keep a tally in Excel by going back to the same cell and ent...

Importing Excel spreadsheet into Acces
This copy of Access 2003 does not appear to have the 'Import Spreadsheet Wizard.' Am I missing something, or what can I do to import from Excel? "firebird9" <firebird9@discussions.microsoft.com> wrote in message news:7EF40A09-0915-4652-9FCA-27A887851DB5@microsoft.com... > This copy of Access 2003 does not appear to have the 'Import Spreadsheet > Wizard.' Am I missing something, or what can I do to import from Excel? I think you're missing something. What happens when you click File -> Get External Data -> Import..., and choose...

CRM and Fax automation question
Hi, I'm looking for a good or better fax server that can be easily and seamlessly integrate with MS CRM 3.0 or 4.0. I'm thinking of RightFAX or GFIFax... or even if I install these fax server in my environment, do I still need to do programming and customizations, such as post callout when a new Fax activity is created? Please advise :) You immediate response is appreciated. "Benjamin Fallar III" <fallar@pldtdsl.net> wrote in message news:3484C69D-B193-4B48-86A4-A4529D9DE4C6@microsoft.com... > I'm thinking of RightFAX or GFIFax... or even if I install ...

Automation
Hello Everyone, Recently our IT group installed service pack 3 on our computers. I wrote some code in word that automatically attaches it self to an outlook email and sends it out. I'de like to disable two windows that i didn't get before they installed service pack 3 there are not titles so here is a description of the boxes: 1 - A program is trying to access email addresses you have store in outlook. do you want to allow this? then it asks for "allow access for" (1,5,10 minutes) 2 - then i get a similar one that just asks you if you're sure you want to send ...

Excel Invoice template
Can any one suggest an invoice template for the British market? ...

Using Excel 2000. All of a sudden none of my formulas wiil work.
i have tried to get help in excel help and it says more information is available on the web, I can't find it. I ran disk cleanup and disk defrag over the weekend. I am running a new computer and transferred my MS Office 2000 to it about 4 months ago and has been working fine until this week. Any help will be greatly appreciated. Thanks in advance Tammy thch91 All of a sudden none of my formulas wiil work. Thanks Tammy "Tammy_91" wrote: > i have tried to get help in excel help and it says more information is > available on the web, I can't find it. I ran...

Setlangcode!b28 in Excel.
Version: 2004 Operating System: Mac OS X 10.6 (Snow Leopard) Setlangcode!b28 in Excel. <br><br>I have just upgraded to 10.6.2 (SL) and work on Office 2004. <br><br>In excel I am trying to set a different language and am getting: <br><br>Macro error at cell: <br> [Set Language] Setlangcode!b28 <br><br>If I try to fix it, it claims the dictionary is not installed in the 'Proofing Tools Folder' however it is and always was. Needles to say it worked fine under 10.5. <br><br>Anybody knows how to fix this? Thanks An...

Excel lost association with .xls files. Must use Excel open comm
Lately I found that I can't double click on an .xls file to launch Excel and open the file. I have to launch Excel then from within Excel open the .xls file. I went into file types to try and re-establish the association with Excel and .xls files without success... Any suggestions? Neil.Krohn@freescale.com Sometimes one of these works: Tools|Options|General|Ignore other applications (uncheck it) --- or --- Close Excel and Windows Start Button|Run excel /unregserver then Windows Start Button|Run excel /regserver The /unregserver & /regserver stuff resets the windows regist...

Provisioning/Automation tools for Exchange??
I have been asked to find some tools possible of automoating mailbox moves to specific databases/storage groups based on the department of a user for instance. Let's say User1 is part of HR and has transferred to Marketing. All the HR mailboxes reside on SG1 DB1 and all Marketing reside on SG1 DB2. Is there any software anyone knows of that can read the department attribute from AD and then move the mailbox according to defined rules you put in place. Any and all help appreciated! Mike In a couple of situations, organizations I have worked in have talked about having something li...

Scanning Barcode, match with excel, VBA
I got a barcode scanner attached to a laptop. I my excel sheet, column A has source#, column B has item to keep or discard. I have a barcode label (source#) on the item in the shelf, so when I scan the barcode label, I want excel to take me to the source# match in the column A. so I will get to see column B to keep the item or to discard. And I also wanted the row to turn green for keep and red to discard. Can anybody PLEASE help with creating VBA using Macro? Column A Column B Source# Keep/discard 1572156 Keep 1572293 Discard 1572299 Keep 1572211 Discard 15723...

Can I view an excell document without excell (not installed wit. #2
can I view an excell document without excell as it is not supplied with the XP home addition. ???????? Good evening You certainly can. Go here : http://tinyurl.com/5az9k for Excel Viewer 2003. HTH -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=18932 View this thread: http://www.excelforum.com/showthread.php?threadid=346054 ...

Excel Cell format Question??
How do I change the default value of a cell from 0 to a different number? A cell has no default number unless you placed it there. OR........do you mean if you enter a formula such as =12*A1 you get 0 if A1 is empty? You could use an IF in your formula. =IF(A1="",yournumber,12*A1) where yournumber is whatever you wish it to be. Gord Dibben Excel MVP On Fri, 1 Oct 2004 09:09:03 -0700, GMoore <GMoore@discussions.microsoft.com> wrote: >How do I change the default value of a cell from 0 to a different number? ...

Is it Possible to Automate a Graph?
I have a sheet that has data in weekly fashion in the first and second rows. (Row 1, week: Row 2, data.) Is it possible to have a graph populate off of the information in rows 1 and 2 that automatically includes data for new weeks as they are entered in to the sheet? For example, I want to create a graph for weeks 1 through 3 now, and want the chart to automatically update if I add data for week 4. Row 1 Week 1 2 3 Data 12.5 17 18 Thanks for the assist! -Adam Use a defined name using the offset function for your series --...

Search a list of string in an excel file
Suppose I have a list of items. Item = {ame is, game, same} I have an excel file with more than one sheet. I have to find the above list in the Excel sheet and report it in a multidimensional array in following format: <Searched String>, <Sheet Name>, <Cell>, <Occurrences>, <Words found> example if the A10 cell of myData sheet contains following string: My name is Sid. My Game is Hockey. My Fame is programming then the code should return: ame is, myData, A10, 3, {name is, game is, fame is} ...

EXCEL
WHY IS IT, WHEN I PRINT AN EXCEL SPREADSHEET, IT PRINTS ADDITIONAL BLANK PAGES? HOW CAN I PREVENT THIS FROM HAPPENING AGAIN? THANK YOU "KIM GEORGE" wrote > WHY IS IT, WHEN I PRINT AN EXCEL SPREADSHEET, IT > PRINTS ADDITIONAL BLANK PAGES? HOW CAN I PREVENT > THIS FROM HAPPENING AGAIN? Because the print range needs to be changed? If so, select the area to be printed, pull down the file menu and select Print area, Set print area. BTW, you might want to hit your caps lock key. Jordon If you SHOUT just a little LOUDER we can hear you better. Try deleting the rows below ...

Way to automate adding pictures in a series in Excel?
I'm putting a column of pictures of people next to a column with their names. If I have the pictures together in a folder, with the photo file names numbered with the corresponding row numbers that the pictures go in, is there a way to record a macro so that (for instance) 28.jpg will go into the picture column in row #28, then 29.jpg will go into the picture column in row #29, etc. In other words, insert a whole series of pictures (filenames the same as their appropriate row numbers) in their correct places, by initiating one macro? If anyone has any idea of how that could be done, I wou...

Building folder-list in Excel
Hey guys You have kindly helped me before, and I dare to consult you again. I want to make a Excel-list of all subfolders in folder - the path = value in cell A1. If there are no subfolders then a msgbox will appear "Folder dos'nt exist". Proberbly a simple VBA-trick - but I'm not that kind of magician ...so..will you please help me again? Best regards Snoopy Option Explicit Private cnt As Long Private arfiles Private level As Long Sub Folders() Dim i As Long Dim sFolder As String Dim iStart As Long Dim iEnd As Long Dim fOutline As Boolean arfiles = Array() cnt = ...

Excell to ASCII fiel
I need to export an excell ss to an ascii file or if this is not possible to a Database file. Thanks Look at your options under File/Save As. Text files and DBASE are both options. On Thu, 30 Oct 2003 13:32:57 -0800, "richard l weston" <richard@tfaxtax.com> wrote: >I need to export an excell ss to an ascii file or if this >is not possible to a Database file. > >Thanks ...

sending excel spreadsheets to cell phones
I'm Scott Gordon with Webalo. We are releasing a new service, the Webalo Mobile Dashboard, and would like to invite you to be a part of our beta program. The Webalo Mobile Dashboard allows you to easily deliver excel spreadsheets that are very easy to read and navigate to mobile devices - including BlackBerry, PocketPC, Treo (700w windows os), and smart phones. We host WebEx demonstrations every Tuesday and Thursday. After the demonstration, we will give you an account that you can use on your own. You can sign up at http://md.webalo.com You can contact me at sgordon@webalo.com. Sc...

How do I put title on top of chart already made in Excel?
Hi, You can add a chart title via the Options dialog. Right click the chart and pick Chart Options from the context menu. On the Titles tab enter text in the chart title text field. Cheers Andy Angel Childre wrote: -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

Excel Do not calculate
Sometimes (not every time) Excel do not calculate different formulas when recalculating worksheets manually. Moreover it can calculate them in some sells and donot calculate in others. All formulas are correct, when you enter a cell and press "Enter" the needed result is given. WorkBook is configured to be recalculated manually. Thanks. Try forcing a complete recalc: This is from xl2002's help: Calculate a worksheet or workbook now Press F9 Calculates formulas that have changed since the last calculation, and formulas dependent on them, in all open workbooks. If a wo...

Automating transfers, is this possible?
Hi All. I am using MM 2007 Premium and I'm using Advanced Bills. In "Help" it says .... "Make electronic transfers. Set up automated transfers between any accounts you track in Money" I have a set up an "xfer" from my checking to my savings (same bank) to occur once a month but Money doesn't actually do anything unless I manually go to "Bills Summary", check it and and click "Pay Online". This isn't what I would call an automated transfer. Is there any way to actually make this happen? Thanks, Richard ----== Posted via ...

Excel 2007 slow saving with defined names
Hello, I am using a worksheet with a lot of defined names. Saving this sheet in Excel 2007 takes about 5 minutes! In previous Excel-versions the same worksheet saves within 10 seconds. Does anyone have an idea to improve this performance? Probably Windows Vista has something to do with this problem, because: - Windows XP and Excel 2007: fast saving - Windows Vista and Excel 2003: fast saving - Windows Vista and Excel 2007: slooooow saving Any ideas? Greeting RI ...