?
Solved

print excel table from c++ in win2000

Posted on 2001-07-10
6
Medium Priority
?
501 Views
Last Modified: 2008-03-10
Hi,

i have an c++ application that use excel com object
(Excel::_ApplicationPtr ).

to print the table we use the details from CPrintDialog object(mfc) in c++.

the problem is:
i cant print in win2000.
i think that it's because CPrintDialog returns the real port name but the algorithm in the excel print property search 4 it in  the registry (so it fail).
the same code works correctly in win95.

HELP !!!!!

the code :

Excel::_ApplicationPtr pXL;

try {
     pXL.CreateInstance(L"Excel.Application.9");
CPrintDialog dlg(FALSE, PD_USEDEVMODECOPIESANDCOLLATE | PD_NOPAGENUMS |PD_NOSELECTION);
               
if(dlg.DoModal() == IDOK)
{
  //**** didnt include all the code :
  //**** b4 i get lots of details ( like copies, page, etc
CString port_name = dlg.GetPortName();
pXL ->PutActivePrinter((LPCTSTR)(dev_name + " on " + port_name));
}


the error code i get is: 800a03ec
0
Comment
Question by:lubaka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:exelrud
ID: 6270279
Have you considered make excel to show the print dialog to the user (like file|Print) ?
0
 

Author Comment

by:lubaka
ID: 6283219
The excell application runs in the background (visable = false), so i cant use any of it's methods/dialogs/etc.

0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6283281
you should be using a BSTR in your call - ps this may not be you problem but you should know about this)

eg

BSTR bstrPrinter=CString(dev_name + " on " + port_name).AllocSysString();
pXL ->PutActivePrinter(bstrPrinter);
::SysFreeString(bstrPrinter);

a BSTR may look like a WCHAR* but it isn't - it has a hidden 4 bytes before the data that contain the length - if you just use a WCHAR* then it is random what 4 bytes are in front of it - you may be lucky you may be not.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 30

Expert Comment

by:Axter
ID: 6284355
Are you using the same version of Excel in both Win95 and Win2000?
Have you tested your code in Win98, WinNT, Win2000-Server?  If so, what was the result?
Are you printing to the same type of printer?

Any thing that has changed from one test-computer to another could be the real cause of the problem.  You should rule-them out first.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6825684
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since you never gave more feedback.

The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 6875463
Per recommendation points refunded and question closed.

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question