Skip to main content
WolfShade
Legend
July 19, 2017
Answered

SpreadsheetCreateSheet - check if sheet already exists?

  • July 19, 2017
  • 1 reply
  • 927 views

Hello, all,

I'm working with SpreadsheetNew and SpreadsheetCreateSheet, populating from a query object.

I've experienced something that I've never seen, before.  If you have a Spreadsheet object and try to add a sheet to it using a name that already exists, CF will abort.  I finally got it to email the reason to me.  "The workbook already contains a sheet of this name."

I am sorting the data on the column (FQDN) that I am using to name the sheets with.  I'm removing "http://" and "https://" from the FQDN and using "www.example.com" as the sheet names.

However, I did not expect for there to be "http://www.example.com" AND "https://www.example.com", so when CF creates "www.example.com", populates the sheet, then tries to create "www.example.com", again, it just stops.

I am not seeing any CF Spreadsheet(blahblahblah) commands that will check to see if a sheet already exists.

I will try to modify the query so that both standard and encrypted FQDNs fall into the same group, but just in case.. can anyone think of a way to check if a particular sheet name already exists within a Spreadsheet object??

V/r,

^ _ ^

    This topic has been closed for replies.
    Correct answer WolfShade

    Well, I did kind of find an answer to my question.  You can use SpreadsheetInfo(obj) to get information about the spreadsheet object, including a column called "SHEETNAMES".  It's a comma-delimited list of the names of currently existing spreadsheets.  I will iterate through that and just make that the active sheet instead of creating it if the name already exists.

    V/r,

    ^ _ ^

    1 reply

    WolfShade
    WolfShadeAuthorCorrect answer
    Legend
    July 19, 2017

    Well, I did kind of find an answer to my question.  You can use SpreadsheetInfo(obj) to get information about the spreadsheet object, including a column called "SHEETNAMES".  It's a comma-delimited list of the names of currently existing spreadsheets.  I will iterate through that and just make that the active sheet instead of creating it if the name already exists.

    V/r,

    ^ _ ^