Read a specific sheet in an excel document. Help, please!

First I start Excel and then I read a specific excel document that has 5 of the sheet and 1 sheet is active:

GetProjectDir (fileName);

strcat (fileName, "\\Logiciel_FH.xls");

error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, fileName, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, & ExcelWorkbookHandle);

Get the sheets in the active workbook

error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets,

CAVT_OBJHANDLE, & ExcelSheetsHandle);

error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt (1), & ExcelWorksheetHandle);

The first sheet Active - should already be active

error = Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);

After I write data in this sheet and start a macro-fonction I want to read the sheet number 4... so I tried to do, but yet it reads 1 sheet.)

error = CA_VariantSetCString (& MyCellRangeV, EXCEL_ARRAY_OF_CELLS);

error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, & ExcelRangeHandle);

CA_VariantClear (& MyCellRangeV);

error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets,

CAVT_OBJHANDLE, & ExcelSheetsHandle);

error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt (4), & ExcelWorksheetHandle);

The first sheet Active - should already be active

error = Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);

Make the range Active

error = Excel_RangeActivate (ExcelRangeHandle, & ErrorInfo, NULL);

Ask the ith by jth value in the range that returns a shipment to a new range of single cell

error = Excel_RangeGetItem (ExcelRangeHandle, & ErrorInfo, CA_VariantInt (12), CA_VariantInt (2), & MyVariant);

Get the pointer of SHIPPING

error = CA_VariantGetDispatch (& MyVariant, & MyDispatch);

Create a Range object pointer for SHIPPING

error = CA_CreateObjHandleFromIDispatch (MyDispatch, 0, & ExcelSingleCellRangeHandle);

Get the value of the range of simple cells

error = Excel_GetProperty (ExcelSingleCellRangeHandle, & ErrorInfo, Excel_RangeValue2, CAVT_VARIANT, & MyVariant);

error = CA_VariantGetCString (& MyVariant, &d);)

printf ("%s\n", d);

CA_VariantClear (& MyVariant);

ClearObjHandle (& ExcelSingleCellRangeHandle);

Can you tell me where I'm wrong...? What should I do to make the reading of the number 4 sheet program?

Advertisement

I used some code that is very similar to yours in the past, with one exception, which is to close the handle to the worksheet active prior to acivating a new. In this case, the code should look like the following (note the red lines):

GetProjectDir (fileName);

strcat (fileName, "\\Logiciel_FH.xls");

error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, fileName, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, CA_DEFAULT_VAL,

CA_DEFAULT_VAL, & ExcelWorkbookHandle);

Get the sheets in the active workbook

error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets, CAVT_OBJHANDLE, & ExcelSheetsHandle);

Handle to the first sheet

error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt (1), & ExcelWorksheetHandle);

The first sheet Active - should already be active

error = Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);

error = CA_VariantSetCString (& MyCellRangeV, EXCEL_ARRAY_OF_CELLS);

error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, & ExcelRangeHandle);

CA_VariantClear (& MyCellRangeV);

Turn the handle to the active worksheet

error = ClearObjHandle (& ExcelWorksheetHandle);

error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets, CAVT_OBJHANDLE, & ExcelSheetsHandle);

Is not necessary: you have not deleted variable ExcelSheetsHandle, which is still topical

Manage the fourth leaf

error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt (4), & ExcelWorksheetHandle);

Make the Active sheet

error = Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);

Make the range Active

error = Excel_RangeActivate (ExcelRangeHandle, & ErrorInfo, NULL);

Ask the ith by jth value in the range that returns a shipment to a new range of single cell

error = Excel_RangeGetItem (ExcelRangeHandle, & ErrorInfo, CA_VariantInt (12), CA_VariantInt (2), & MyVariant);

Get the pointer of SHIPPING

error = CA_VariantGetDispatch (& MyVariant, & MyDispatch);

Create a Range object pointer for SHIPPING

error = CA_CreateObjHandleFromIDispatch (MyDispatch, 0, & ExcelSingleCellRangeHandle);

Get the value of the range of simple cells

error = Excel_GetProperty (ExcelSingleCellRangeHandle, & ErrorInfo, Excel_RangeValue2, CAVT_VARIANT, & MyVariant);

error = CA_VariantGetCString (& MyVariant, &d);)

printf ("%s\n", d);

CA_VariantClear (& MyVariant);

ClearObjHandle (& ExcelSingleCellRangeHandle);

As a side note, you don't use error checking and probably have disabled the break on errors in the library: you should have received an error when you try to access the new sheet: consider to add proper error management and be sure that in this case to clear all objects active before leaving the service.

Tags: NI Software

Similar Questions

  • I m using HP 6730 b... win 8... fingerprint reader not working do not... Help, please!

    I m using HP 6730 b... I installed win 8... My fingerprint reader does not... what I would do. Help, please!

    Windows 8 is NOT supported for use on your laptop. The best you can do is try to download and install the Windows 7 driver.

    If it doesn't work, it's most likely game over... Look for the "AuthenTec driver in the list

    http://WWW8.HP.com/ca/en/support-drivers.html

  • Can not find the pre-selection adjustment Local documents - help, please?

    After that technicians Apple wiped my MacBook Pro, I reinstalled all my apps, including 6 Lightroom (CC).  No problem with purchased downloads or the addition of my presets. But oh no! When I tried to add my brushes bought, I could not find the folder of Local adjustment Preset! Where would it be?

    Here's what I see when I click on the folder presets button. Do you have any suggestions as to other where I could look at? I tried Adobe & se troubleshooting forums, but no luck.

    Thanks in advance for any suggested of bugs!

    Screen Shot 2016-05-06 at 10.03.16 PM.png

    Oh hey, I found a solution in another post, only tangentially related. Thank you to skproductions303 for this!  (Copy and paste the solution here, in quotes, in the case where someone else has the same problems.)

    "I had the same problem, just bought a new Macbook Pro (June 2015) and Lightroom CC was this mistake as well."  Here is the dialog box that I've had with Adobe, and it cures the problem:

    Adobe: Please click on the search option in your Dock at the bottom of the screen.

    Adobe: Then click GO on the MenuBar at the top of the screen.

    Adobe:, and then click GO to folder, and then type: ~/Library/Application Support/Adobe /.

    Scott: OK, I did

    Adobe: Control-click on the folder and choose read information.

    Adobe: Expand the section sharing & permissions.

    Adobe: Click on + icon, and check if the administrator select

    Scott: OK, I chose the Admin

    Adobe: Give read and write to the Admini

    Scott: completed

    Adobe: Click the gear icon and select apply changes to included items

    Scott: OK

    Adobe: In the Finder window, click GO and select GO to folder

    Adobe: Type in
    Adobe: / Library/Application Support/Adobe
    / and press enter

    Scott: completed

    Adobe: Control-click on the folder and choose read information

    Adobe: Expand the section sharing & permissions.

    Scott: ok

    Adobe: Give read and write permissions to all users

    Adobe: Then click on the sign + and add the rest of the users from the list

    Scott: completed

    Adobe: Now, please try to use the Lightroom from your computer.

    Scott: Thank you - it works! »

  • VERY, VERY strange table import/excel/number - help please

    Hello

    I met a troubling problem when you import data tables in InDesign from Excel. This is the standard binder with named tabs. The value-"1.0" will not import into InDesign. he refuses. If manually, I go in the Excel file and change the cell containing the value of 'Number' to 'Text' it will be important, but it's not scalable or possible when monthly reports comes through and dozens of tables are automatically transmitted to.

    Is this a know bug? I can't find details online.

    Help?

    Macintosh 10.9.4, Indesign CC

    Thank you

    I also tested on InDesign CS6 and Windows as well. I am answering it/update in order to help someone else having the same problem.

    I continued troubleshooting Excel files and determined using the .xlsx extension are the main culprit.

    All the data of fine imports during registration as .xls (97-2004)

  • There is a problem with the Adobe Acrobat Reader etc. etc. 103 error code? Help please

    Question of Acrobat Reader of Adobe as above - downloaded the last questions once again still the version. I use an old Acer laptop with Windows XP, which I only use now for printing

    Thanks, but I already had the 11.0.08 version that I don't see that 09 is available? I think having solved the problem for the time being but the uninstall and replace it with an older version 10.1.4. If your suggestion I helped sort of Ta

  • Contact sheets for PSE9... help please. :)

    At my office, the latest version, we had was PSE2... Gasp! Contact sheets were so simple and I tried and tried to figure out how to make them in Photoshop Elements 9, nothing is. For example, I want to print 10 images (all contents in a folder on our server) - 2 per page. Please please help. I'm amazed at how much we relied on this feature. Thank you!

    Try the elements Organizer 9 photoshop under the print settings.

    Photoshop elements 9 is perfectly good software, so feel free to upgrade.

    There is just a slight learning curve because of some of the differences between pse2 and pse9.

    Rather than use folders, you must import your images in the Organizer.

    MTSTUNER

    Post edited by: MTSTUNER

  • How can I associate different sheets in the same document?

    Hello (and sorry for my English, I hope, you will understand my request),

    Using Excel, I used your link to multiple sheets with one another in the same document, using the "paste special / paste with binding" (not sure of the translation) and then "paste special / format. It's a fantastic tool, which allows me to have different aspects of my master sheet, all being updated automatically as soon as the captain we changed. I have had up to 10 sheets in the same document linked to that of master, each containing what was strictly necessary for each single service, I was working with.

    I know that I can have the same result on numbers with cells, using '=', but is there a way I can do it for a whole sheet?

    Thank you

    frantchoua @ wrote:

    I know that I can have the same result on numbers with cells, using '=', but is there a way I can do it for a whole sheet?

    Try to use = to answer a single cell on the other sheet.  Then copy this formula right and down.  Who should have the same effect as selecting a range in Excel followed edition > paste special > paste with binding.

    SG

  • won't print excel documents

    We have a Dell Vostro 200 desktop computer that we have recently upgraded from Windows XP to Windows 7.  We have a HP Photosmart c5580 all-in-one printer.  I have Microsoft Office 2003.  Recently downloaded HP driver version 13.0 for internet software.  I can print anything but a document/spreadsheet excel.  Error message says something about "Ne03.  What is the problem?

    Redfletcher,

    Thanks for the information. I want to you to try to create a new Excel spreadsheet. Office programs tend to store the old hardware information which can have references. You want to print the existing sheets?

    Create the new sheet, it does not print? If this print then you will need to recreate your old sheets, or you can contact the Microsoft Office Support and see if there is a better way to solve this problem for you. Because the problem is only with Excel and other documents are able to print on your printer C5500 series, we know that the printer and the software are very good.

    You also have the option to use Microsoft Fixit to try and troubleshoot MS Office, click on the link below to get started:

    Attach it to MS

    I hope that this helps, please let me know what happens when you create a new Excel sheet.

  • Excel documents is always moving on desktop

    I am running Windows 7 64 bit, all updates installed, but it will probably work on most of the Windows 7 machines.
    I don't have an English version of Windows, but I'll try to explain reproduction.

    I like my icons on the desktop that will be organized, so I do not use auto arrange. Group in my own way specific icons. The left side of my screen is almost empty. My problem is that when I edit an Excel document that is located on the desktop, the icon moves the default location (left) of the screen. Here's how:

    1. on your desktop, turn off the auto arrange. (right click on desktop-> menu 'View'-> point "auto arrange")
    2. on the desktop right click somewhere on the right side of the screen and create a new Excel document. (right click on desktop-> menu 'new'-> point ' Microsoft Excel-document ')
    3. make sure that the new document is NOT on the default location (left) of the screen. If, goto 1 or try to drag it to the right of the screen. :)
    4. open the Excel document, that you just created and save it (with or without editing). (recording with CTRL + S, so NOT "Save as...") »).
    5. open your desktop, again, by closing or minimizing the Excel document. The icon was moved to the location of the default icon.

    I tried this with other documents, but only Excel documents seem to be moving

    I use Windows 7 x 64 as well and when I open an Excel document which is somewhere in the middle of my screen, it creates a hidden file temporary Excel on the left side and this file is deleted when I close the original document. The original document remains in its original location.

  • Excel documents

    I can't access my excel document corner to resize

    Have you tried clicking on the green button? This should toggle the size of the window to fit the screen.

    Another option... I don't know whether or not OS 10.9 has this ability, but move your cursor to the top of the document window and the cursor turns into an arrow pointing down. You can then drag from the top down to resize the window. Then you can drag the window to the top to get to the bottom.

  • import different tables of different sheets of an excel file

    Hello

    The task is to get several (different) arrays that are in different sheets of an excel file. I tried to use the report generation tool, get Excel spreadsheet, Excel get the data functions. but the problem there is that Excel get worksheet function requires a contribution of report. but I only have an excel input file and I can't feed that. Y at - it an alternative to this?

    Simply create a report using the new report.  Wiring in the path to your Excel file as the 'template '.  In addition, make sure you have the report when you are finished with it.

  • all my word and Excel documents all appear in the files my images. If I delete the document of MY photos it is deleted in Word/Excel too, how to undo it?

    Word and Excel files are saved in Word and Excel and in my images.  If I delete the document of my images, it is also deleted in Word / Excel.  I checked and all Word/Excel documents are in my pictures including documents several years ago.

    Can someone tell me why this is happening so Ican break & he has not reproduce? Is this related to the theScan function?  My husband scanned something recently

    You have them saved to this location for some reason any. If you don't like that you have to move them to the correct location and stop then save in the wrong location.

    Whenever you save something you must check if you save it in the correct location, of course.

    Do not delete them. You can use UNDO and trash to get back those you've accidentally deleted recently.

  • Read only specific byte

    I have a continuous flow of incoming data through my serial port. Basically I want to Labview to wait for the '08' byte to arrive to the serial port and then read this and the two following bytes.

    The problem is that I have no idea how to do to isolate this specific section of bytes from a stream of continuous data. It does not appear on a regular basis (only when an event occurs on the device), and I have to be able to read it seems (not only the first time) every time.

    I have used the VISA read / write process before, but never for something like that, and I'm really at a loss. Any help would be much appreciated.

    Brian

    You could configure byte 08 as a character of endpoint and activate the termination characters.  Read a large number of bytes.  The reading will be either timeout, acquire the large numbers of bytes, or return to what she received up to and including the 08.  Now, if you want to read a specific number of bytes after that, then a reading of this number of bytes.

    Probably best is to simply read the serial port at all times and search for byte 08 that may appear in the string and to analyze the data accordingly based on the place where 08 occurs.

  • That is, the output when open the Word or Excel document in Sharepoint

    OS: Windows XP 32 bit sp3

    IE8

    When try click on open the Word document or Excel stored in Sharepoint, exit full of Internet Explorer.

    I suspect that the cause may be due to

    1 installed Microsoft Visual C++ 2008. or

    2. I made a few changes on the associated C++ registry key. But do not remember what changes were made.

    I installed Chome. There is no question to open the Word or Excel document stored in Sharepoint

    If anyone can help.

    Thank you

    See Jimmy

    Hello

    I suggest you to report your charly in the Technet forum for better support.

    http://social.technet.Microsoft.com/forums/en-us/category/SharePoint/

  • Downloaded an Excel document, e-mail, has changed and saved but now cannot find the revised copy

    I downloaded an excel document created on my computer in XP and sent by e-mail to someone else.  I went to my email address on my computer of husbands, active uses vista, downloaded the excel file, I sent my email, changed and saved.  I thought.  now, I don't know and I don't have the data to revise again.  can someone please help!

    * original title - download dilemma *.

    Hey ramona Roberts,

    Unfortunately, you have not saved the excel file on the hard disk of the computer after review.

    Whenever you download a file from the internet or send its recommended to save it to the computer hard disk first and later change, so that you don't lose any information on the file.

Maybe you are looking for

  • What is the alternative to the Flash from Adobe that is blocking Firefox.

    reviews Adobe is blocked by Firefox, I can use instead.

  • CRio-9035 offline development

    In the near future, I develop software for crio-9035. Given that shipping takes a while, I would like to start writing Victorian code now without any hardware. I have installed: LabView - 13; -In time real Module 13. Module FPGA - 13; And then, of co

  • R51 USB problem

    I plugged a usb device to a laptop of R51 that we use here at the office, for rental, and when I did the reset of the computer.  Since then, I can't recognize anything that is plugged into the usb ports. The device I plugged was a cradle on a device

  • Brand new dv7-7212nr want missing SW or config for SSD?

    Just bought a new non-custom desire dv7-7212nr 2 days ago.  Main specifications are: 3rd gen i7-3630QM 750 GB 7200 RPM HARD drive Drive hard acceleration Cache 32 GB SSD 8 GB OF SDRAM Windows 8 Other components are irrelevent to my questions or situa

  • How to add radio buttons to the form

    Hello I want to add option buttons to the form. I wrote the following code: Rbg RadioButtonGroup = new RadioButtonGroup(); RadioButtonField r1 = new RadioButtonField ("first option button"); RadioButtonField r2 = new RadioButtonField ("second radio b