 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
andyH Guest
|
Posted: Wed May 31, 2006 3:15 pm Post subject: TExcelApplication Problem |
|
|
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
|
Posted: Thu Jun 01, 2006 8:08 pm Post subject: Re: TExcelApplication Problem |
|
|
"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 |
|
 |
|
|
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
|
|