Solved

print excel table from c++ in win2000

Posted on 2001-07-10
6
495 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Writing a parser for java language 4 100
Best book to learn C++ 4 96
Header Errors LNK2019, LNK1120 - Unresolved Externals 4 310
Create a path if not exists 7 124
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…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

732 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