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
Solved

print excel table from c++ in win2000

Posted on 2001-07-10
6
486 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 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