none
Passing by reference to an Excel web service function call RRS feed

  • Question

  • Hello,

    I am aware that you can pass by value to an Excel web service function call, but can you pass by reference?

    For example, you can pass the value of the currently selected cell, but can you pass a handle to the current cell, which would enable you to manipulate a cell object variable from within the code body of the related Excel web service function? If not, is there a way for the Excel web service function to use brute force (e.g., by iterating through all open workbooks) to find a handle to the open workbook that made the call?

    Many thanks.

    Keith


    R K Howard

    Saturday, October 27, 2018 1:20 PM

Answers

  • >I want to pass the first cell object and the last cell object (not their values).

    That's not possible, as I tried to explain last time you can't pass objects of any type in a url.

    Sunday, October 28, 2018 7:42 PM
    Moderator

All replies

  • The WebService function only passes a value, a url, and returns whatever value the url/webservice returns. It cannot pass an object byref or byval.

    I assume you're calling the webservice function in your own routine, maybe the webservice could accept the details of the cell say at the end of the url, its address perhaps, and return instructions to your routine to change the cell properties, or perform some other action.

    Saturday, October 27, 2018 6:17 PM
    Moderator
  • Hi.

    Thanks for your reply.

    To be more specific:

    I have successfully used the =WebService() Excel function to pass, say, "ThisIsText" and receive back to the workbook the value "This Is Text", i.e. my Dot Net web service code inserts spaces between words.

    Now, I am trying to do the following:

    Given that Excel does not seem to have a built-in Concatenate function that enables you to specify a start cell and an end cell (you need to specify a comma-delimited list of each cell that you want to concatenate), I would like to use the WebService function to pass a starting cell address and an ending cell address and receive back that concatenation of the contents of all cells in between. To do that, the Dot Net code that I write needs to have access to starting and ending cell variables. This is very different from the first example above.

    Does that clarify my intentions?

    Many thanks.

    Keith


    R K Howard

    Saturday, October 27, 2018 6:34 PM
  • Does that clarify - only slightly!

    If I follow you want to pass a CSV list of cell values to your webservice(?). Shouldn't be too difficult, maybe not comma but some other separator that can be included in the url, # perhaps.

    arr = Range.Value2
    for each v in arr
    strCSV = v & ","

    Not sure if the WebService function is the best way, "POST" perhaps  then "GET" (but don't ask me specifically how!). Or save the 'range value' to a csv file and upload it...

    Sunday, October 28, 2018 8:58 AM
    Moderator
  • Hello,

    I do not want to pass a CVS list of cell values to the web service.

    I want to pass the first cell object and the last cell object (not their values). Then, I want the code in the web service to concatenate the values of all cells that sit between those 2 cell objects.

    I don't know if it is possible to pass objects like this to a web service.

    Thanks.

    Keith


    R K Howard

    Sunday, October 28, 2018 1:19 PM
  • >I want to pass the first cell object and the last cell object (not their values).

    That's not possible, as I tried to explain last time you can't pass objects of any type in a url.

    Sunday, October 28, 2018 7:42 PM
    Moderator