BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TExcelApplication Problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder
View previous topic :: View next topic  
Author Message
andyH
Guest





PostPosted: Wed May 31, 2006 3:15 pm    Post subject: TExcelApplication Problem Reply with quote



I am trying to simply open Excel and paste some tab delimited text into the
work sheet. What I have up to now works, but with only one problem, I can't
make Excel visible.

What I have:
OleVariant Template = EmptyParam;
OleVariant NewTemplate = False;
aExcelApplication = new TExcelApplication(Application);
aExcelWorkbook = new TExcelWorkbook(Application);
aExcelWorksheet = new TExcelWorksheet(Application);
aExcelApplication->Connect();
aExcelApplication->set_Caption(StringToOleStr("My Title"));
aExcelApplication->Workbooks->Add(Template, NewTemplate);
aExcelWorkbook->ConnectTo(aExcelApplication->ActiveWorkbook);
aExcelWorksheet->ConnectTo(aExcelWorkbook->ActiveSheet);
aExcelWorksheet->Paste();

I know this has worked because when I close my app and call:
aExcelApplication->Disconnect();
I get the message "do you want to save changes" and the file I save contains
the data I pasted.

But, how to I make Excel visible?

With TWordApplication I use:
aWordApplication->GetDefaultInterface()->Visible = true;

But if I try :
aExcelApplication->GetDefaultInterface()->Visible = true;
I get the error Visible is not a member of _Application.

Any help greatfuly recieved.
Back to top
andyH
Guest





PostPosted: Thu Jun 01, 2006 8:08 pm    Post subject: Re: TExcelApplication Problem Reply with quote



"andyH" <mr (AT) nowhere_here_anyway (DOT) com> wrote in message
news:vPSdnZZTI-KNHODZRVnyvQ (AT) bt (DOT) com...
Quote:
I am trying to simply open Excel and paste some tab delimited text into the
work sheet. What I have up to now works, but with only one problem, I
can't make Excel visible.

What I have:
OleVariant Template = EmptyParam;
OleVariant NewTemplate = False;
aExcelApplication = new TExcelApplication(Application);
aExcelWorkbook = new TExcelWorkbook(Application);
aExcelWorksheet = new TExcelWorksheet(Application);
aExcelApplication->Connect();
aExcelApplication->set_Caption(StringToOleStr("My Title"));
aExcelApplication->Workbooks->Add(Template, NewTemplate);
aExcelWorkbook->ConnectTo(aExcelApplication->ActiveWorkbook);
aExcelWorksheet->ConnectTo(aExcelWorkbook->ActiveSheet);
aExcelWorksheet->Paste();

I know this has worked because when I close my app and call:
aExcelApplication->Disconnect();
I get the message "do you want to save changes" and the file I save
contains the data I pasted.

But, how to I make Excel visible?

With TWordApplication I use:
aWordApplication->GetDefaultInterface()->Visible = true;

But if I try :
aExcelApplication->GetDefaultInterface()->Visible = true;
I get the error Visible is not a member of _Application.

Any help greatfuly recieved.


Solved it by using:
long lcid=GetUserDefaultLCID();
aExcelApplication->set_UserControl(true);
aExcelApplication->set_Visible(lcid,true);

I hope this helps someone else.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.