Loading ...
Sorry, an error occurred while loading the content.

ActiveXObject Assignment Generates 'Bad Assignment' Error

Expand Messages
  • jamrsim@yahoo.com
    I have a code sample that demonstrates my issue, I m going for 100% error free jslint coverage. The code functions fine. I believe this to be the way in
    Message 1 of 4 , May 18, 2011
    • 0 Attachment
      I have a code sample that demonstrates my issue, I'm going for 100% error free jslint coverage. The code functions fine. I believe this to be the way in which an assignment must occur for an ActiveX property.

      The error I receive is:
      Error:
      Problem at line 10 character 25: Bad assignment.
      xlSheet.Cells(1, 1) = 'Test';
      Problem at line 10 character 25: Stopping. (66% scanned).

      Is there a way to skip just this line, such as
      /*jslint ignore: true*/ prior to the assignment and
      /*jsline ignore: false*/ after? I didn't see anything like that in the documentation.

      Code:

      /*jslint windows: true, maxerr: 50, indent: 4 */
      function init() {
      var xlObj,
      xlBook,
      xlSheet;

      xlObj = new ActiveXObject('Excel.Application');
      xlBook = xlObj.Workbooks.Add();
      xlSheet = xlBook.Worksheets(1);
      xlSheet.Cells(1, 1) = 'Test'; // This line errors
      xlObj.WindowState = 2;
      xlObj.WindowState = 1;
      xlObj.Visible = true;
      }

      THANKS!
    • Douglas Crockford
      ... That line is not valid JavaScript. It is some weird Microsoft thing. Isn t there a way to set your cell using the language correctly?
      Message 2 of 4 , May 18, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, jamrsim@... wrote:
        >
        > I have a code sample that demonstrates my issue, I'm going for 100% error free jslint coverage. The code functions fine. I believe this to be the way in which an assignment must occur for an ActiveX property.
        >
        > The error I receive is:
        > Error:
        > Problem at line 10 character 25: Bad assignment.
        > xlSheet.Cells(1, 1) = 'Test';
        > Problem at line 10 character 25: Stopping. (66% scanned).
        >
        > Is there a way to skip just this line, such as
        > /*jslint ignore: true*/ prior to the assignment and
        > /*jsline ignore: false*/ after? I didn't see anything like that in the documentation.

        That line is not valid JavaScript. It is some weird Microsoft thing.
        Isn't there a way to set your cell using the language correctly?
      • Frederik Dohr
        ... I m barely familiar with ActiveX, but perhaps something like this: var cell = xlSheet.Cells(1, 1); cell.value = Test ; -- F.
        Message 3 of 4 , May 18, 2011
        • 0 Attachment
          >> Problem at line 10 character 25: Bad assignment.
          >> xlSheet.Cells(1, 1) = 'Test';
          >
          > That line is not valid JavaScript. It is some weird Microsoft thing.
          > Isn't there a way to set your cell using the language correctly?

          I'm barely familiar with ActiveX, but perhaps something like this:

          var cell = xlSheet.Cells(1, 1);
          cell.value = 'Test';


          -- F.
        • jamrsim@yahoo.com
          Thanks Douglas and Frederik. Combine the two responses and I have my answer. Thanks, worked like a charm. Appreciate the help!
          Message 4 of 4 , May 18, 2011
          • 0 Attachment
            Thanks Douglas and Frederik.

            Combine the two responses and I have my answer. Thanks, worked like a charm. Appreciate the help!

            --- In jslint_com@yahoogroups.com, Frederik Dohr <fdg001@...> wrote:
            >
            > >> Problem at line 10 character 25: Bad assignment.
            > >> xlSheet.Cells(1, 1) = 'Test';
            > >
            > > That line is not valid JavaScript. It is some weird Microsoft thing.
            > > Isn't there a way to set your cell using the language correctly?
            >
            > I'm barely familiar with ActiveX, but perhaps something like this:
            >
            > var cell = xlSheet.Cells(1, 1);
            > cell.value = 'Test';
            >
            >
            > -- F.
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.