This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Sep 4, 2014, 5:57 PM
10 Posts
topic has been resolvedResolved

Creating multiple Worksheets in Excel 2013 using Lotus Script

  • Category: Domino Designer
  • Platform: All Platforms
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 2

We have built code to export information from a database to an Excel workbook.  It works fine for EXCEL 2007 but fails when the user has EXCEL 2013.   on building the automation object.  Here is the section of code that fails when the 2nd worksheet is being set.  (dpsheet).   Does anyone have a possible workaround?
 

Dim application As Variant
Dim sheet As Variant
Dim dpSheet As Variant
Dim dpaSheet As Variant

Set application = CreateObject("Excel.Application")
    application.Visible = True
    application.Workbooks.Add
    application.Workbooks(1).Activate
    
    Set sheet = application.Workbooks(1).Worksheets(1)
      
    
    If achoice = "All Reports" Or achoice = "Out of Date" Then
        
        Set sheet = application.Workbooks(1).ActiveSheet
        sheet.Name = "Overdue"
        
        If achoice = "All Reports"  Then
            Set dpSheet = application.Workbooks(1).Worksheets(2)
            dpSheet.Name = "Approval Started"
            Set dpaSheet = application.Workbooks(1).Worksheets(3)
            dpaSheet.Name = "All Docs"
            
        End If
    End If

Sep 10, 2014, 4:53 PM
10 Posts
Excel 2013

Haven't tried this yet, but I believe Excel 2013 only gives you one worksheet by default, so instead of just switching to application.Workbooks(1).Worksheets(2) you'll need to create the worksheets first. Should be something like

set dpSheet = application.Workbooks.add

 

Sep 19, 2014, 3:40 PM
10 Posts
Creating multiple Worksheets in Excel 2013 using Lotus Script

Finally got this to work - have to add sheet to workbook differently because Excel 2013 starts with only one worksheet in a workbook by default instead of 3.  Because I have users that have earlier versions of Excel as well I have to check on version as well.   Excel 2007 is Version 12.0   Excel 2013 is Version 15.0.

Set application = CreateObject("Excel.Application")
    appver = application.version
    application.Visible = True
    
    If application.version <= "12.0"  Then
        application.Workbooks.Add
        application.Workbooks(1).Activate

    else
        Set workbook = application.Workbooks.Add
        workbook.activate
        Set colSheets = Workbook.Sheets
        colSheets.Add ,,2
    End If
                
    Set sheet = application.Workbooks(1).Worksheets(1)
        
    If achoice = "All Reports" Or achoice = "Out of Date" Then
        
        Set sheet = application.Workbooks(1).ActiveSheet
        sheet.Name = "Overdue"
    
        Set dpSheet = application.Workbooks(1).Worksheets(2)
        Set dpaSheet = application.Workbooks(1).Worksheets(3)
        dpSheet.Name = "Approval Started"
        dpaSheet.Name = "All Docs"
            
    End If


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal