+ Reply to Thread
Results 1 to 4 of 4

How to get all the sheetname in Excel via COM?

  1. #1
    Registered User
    Join Date
    08-10-2008
    Location
    China
    Posts
    24

    How to get all the sheetname in Excel via COM?

    Hi everyone,

    Could you please tell me how to get all the sheet name in the Excel via COM? Following is the code snippet of C++, I can get the count of all the excel sheet in the excel, But I can't get the name of sheet.... Could you please take a look at it?

    Code snippet:

    Please Login or Register  to view this content.
    Thanks^_^
    Winnie

  2. #2
    Registered User
    Join Date
    07-22-2008
    Location
    DELHI
    Posts
    11

    make a commandbutton on excel sheet and Use this code

    Please Login or Register  to view this content.
    Last edited by royUK; 08-20-2008 at 07:52 AM. Reason: add code tags

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by pankajkaushik12 View Post
    Private Sub CommandButton1_Click()
    MsgBox "the count of workbook is=" & Worksheets.Count

    For i = 1 To Worksheets.Count
    Cells(i, 1) = Worksheets(i).Name
    Next i
    End Sub
    Please read the Forum Rules & use Code Tags when appropriate.

    I don't think the OP is looking for a VBA solution.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    08-10-2008
    Location
    China
    Posts
    24
    Thanks a lot to ALL of you^_^
    I have found the solution for that, please refer to the code below:
    for(int i=1; i<=iSheetCount; i++)
    {
    lpDisph = m_ExcelSheets.GetItem(COleVariant((long)i));
    m_ExcelSheet.AttachDispatch(lpDisph);
    CString str = m_ExcelSheet.GetName();
    m_ExcelApp.SetDisplayAlerts(TRUE);
    i=iSheetCount;
    }
    }
    Because I have to use C++ to complete it. And I didn't find too much sample about it......

    Thanks
    Winnie
    Last edited by winniewang11; 08-20-2008 at 10:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 03-12-2008, 09:14 AM
  2. Filter external data based on value in Excel?
    By obiwaynekenobi in forum Excel General
    Replies: 1
    Last Post: 01-24-2008, 11:55 PM
  3. Excel Macro - Read excel & read excel range - save as text
    By se.sathish in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2008, 09:00 AM
  4. new instance Excel application
    By extreme in forum Excel General
    Replies: 3
    Last Post: 06-25-2007, 12:41 AM
  5. how to merge data from one excel into another excel
    By refreshplease3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2006, 08:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1