Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get list of worksheet names using VC++ [modified]

How to get list of worksheet names using VC++ [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutoriallearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gtag
    wrote on last edited by
    #1

    I am using following imports: //Mircorsoft Office Objects #import \      "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE12\mso.dll"\      rename("DocumentProperties", "DocumentPropertiesXL")\      rename("RGB", "RBGXL") //Microsoft VBA Objects #import \      "C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" //Excel Application Objects using namespace Office; #import "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"\      rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL")\      rename("DocumentProperties", "DocumentPropertiesXL")\      rename("ReplaceText", "ReplaceTextXL")\      rename("CopyFile", "CopyFileXL")\      exclude("IFont", "IPicture") no_dual_interfaces Excel::_ApplicationPtr XL; Excel::_WorkbookPtr book; Excel::_WorksheetPtr sheet; By using for loop ,able to get all workbook names.Using following code iterating through item, getting all workbook names. book = XL->Workbooks->Item[1]; In case of worksheet, i am not getting the name of worksheet.There is no such option as workbook. Able to point to particular sheet, but name option is not there. sheet = XL->Workbooks->Item[1]->Sheets->Item[1]; I want to retrieve whole list of worksheets present in workbook. Googled but I didn't get any clue. If there is any option, please give me clue. Thanks in advance. Gtag. Hey if any one knows, please give me clue.

    modified on Tuesday, September 29, 2009 9:29 AM

    S 1 Reply Last reply
    0
    • G gtag

      I am using following imports: //Mircorsoft Office Objects #import \      "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE12\mso.dll"\      rename("DocumentProperties", "DocumentPropertiesXL")\      rename("RGB", "RBGXL") //Microsoft VBA Objects #import \      "C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" //Excel Application Objects using namespace Office; #import "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"\      rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL")\      rename("DocumentProperties", "DocumentPropertiesXL")\      rename("ReplaceText", "ReplaceTextXL")\      rename("CopyFile", "CopyFileXL")\      exclude("IFont", "IPicture") no_dual_interfaces Excel::_ApplicationPtr XL; Excel::_WorkbookPtr book; Excel::_WorksheetPtr sheet; By using for loop ,able to get all workbook names.Using following code iterating through item, getting all workbook names. book = XL->Workbooks->Item[1]; In case of worksheet, i am not getting the name of worksheet.There is no such option as workbook. Able to point to particular sheet, but name option is not there. sheet = XL->Workbooks->Item[1]->Sheets->Item[1]; I want to retrieve whole list of worksheets present in workbook. Googled but I didn't get any clue. If there is any option, please give me clue. Thanks in advance. Gtag. Hey if any one knows, please give me clue.

      modified on Tuesday, September 29, 2009 9:29 AM

      S Offline
      S Offline
      Steve144
      wrote on last edited by
      #2

      // --- Print worksheet names Excel::_WorksheetPtr p_sheet; m_lngWorksheets = m_xLBook->Worksheets->Count; TRACE("Number of Worksheets is <%d>\n", m_lngWorksheets ); for ( ico=1;ico<=m_lngWorksheets;ico++ ) { p_sheet = m_xLBook->Worksheets->Item[ico]; _stprintf(p_szBuffer, _T("%s"), (LPCTSTR)p_sheet->Name); TRACE("Worksheet %d Name is %s\n", ico, p_szBuffer ); }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups