-
July 2nd, 2021, 02:34 AM
#1
How to Add new sheet to the end?
Hi,
I have searched a lot of post but still haven't found an answer, the code I use is as follows:
HTML Code:
Excel::WorksheetsPtr ws = Worksheets->GetItem(Worksheets->Count); <<-- last worksheet
//Syntax: IDispatchPtr Sheets::Add ( const _variant_t & Before, const _variant_t & After,
// const _variant_t & Count, const _variant_t & Type, long lcid );
Worksheets->Add(vtMissing, ws, <<-- add to last
1, vtMissing, (long)Excel::xlWorksheet));
This doc say:
HTML Code:
After Optional Variant An object that specifies the sheet after which the new sheet is added.
but how to convert IDispatchPtr to _variant_t ?
Thanks you!
Last edited by Dang.D.Khanh; July 2nd, 2021 at 03:30 AM.
Reason: Missing Tag c++,excel
-
July 2nd, 2021, 01:41 PM
#2
Re: How to Add new sheet to the end?
Originally Posted by Dang.D.Khanh
...
but how to convert IDispatchPtr to _variant_t ?
Thanks you!
Did you try ( from https://docs.microsoft.com/en-us/cpp...?view=msvc-160 )
Code:
_variant_t(
IDispatch* pDispSrc,
bool fAddRef = true
) throw( );
Victor Nijegorodov
-
July 3rd, 2021, 10:33 AM
#3
Re: How to Add new sheet to the end?
Hi Sir,
Thanks for the reply!
I'm having issues with compiling some other lines of code so I can't run the project.
I will try to compile it and come back soon
Last edited by Dang.D.Khanh; July 3rd, 2021 at 10:44 AM.
-
July 3rd, 2021, 01:02 PM
#4
Re: How to Add new sheet to the end?
Hi Sir,
This is exactly what I need. My problem is solved !
-
July 3rd, 2021, 01:52 PM
#5
Re: How to Add new sheet to the end?
Glad you have solved it!
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|