Excel report using old version of MS excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shakss2
    New Member
    • Dec 2007
    • 19

    Excel report using old version of MS excel

    Hello all,

    Im displaying a report in excel.

    below is my code:

    Dim strPath As String
    ' Current path
    strPath = CurrentProject. Path & "\Adhoc_Report. xls"
    'New workbook object
    Dim sh As Workbook
    DoCmd.OutputTo acOutputTable, "test2", acFormatXLS, strPath, 1
    'Setting obj
    Set sh = CreateObject(st rPath)
    'sh.ActiveSheet .Cells.EntireCo lumn.AutoFit
    sh.ActiveSheet. Cells.ColumnWid th = 23
    sh.ActiveSheet. Cells.EntireRow .AutoFit

    The excel workbook is a Microsoft excel 5.0/95 Workbook.
    But the system has the 2003 version installed.
    cuz of this old version my report has cell limit of 255 only which truncatest the data.

    I strongly believe I should be able to specify the version to be used in my code.
    help with the code will be grately appreciated.

    Thanks
    Shaq
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Shakss2
    Hello all,

    Im displaying a report in excel.

    below is my code:

    Dim strPath As String
    ' Current path
    strPath = CurrentProject. Path & "\Adhoc_Report. xls"
    'New workbook object
    Dim sh As Workbook
    DoCmd.OutputTo acOutputTable, "test2", acFormatXLS, strPath, 1
    'Setting obj
    Set sh = CreateObject(st rPath)
    'sh.ActiveSheet .Cells.EntireCo lumn.AutoFit
    sh.ActiveSheet. Cells.ColumnWid th = 23
    sh.ActiveSheet. Cells.EntireRow .AutoFit

    The excel workbook is a Microsoft excel 5.0/95 Workbook.
    But the system has the 2003 version installed.
    cuz of this old version my report has cell limit of 255 only which truncatest the data.

    I strongly believe I should be able to specify the version to be used in my code.
    help with the code will be grately appreciated.

    Thanks
    Shaq
    Try:
    [CODE=vb]
    DoCmd.OutputTo acTable, "Test2", "MicrosoftExcel Biff5(*.xls)", strPath", 1[/CODE]

    Comment

    • Shakss2
      New Member
      • Dec 2007
      • 19

      #3
      Hey Thanks for that reply...

      But im getting the following error if I use this:
      Runtime error 429
      ActiveX component cant create object

      But if I use the below code, it works:
      DoCmd.OutputTo acOutputTable, "test2", acFormatXLS, strPath, 1

      Below is the complete code:
      Dim strPath As String
      ' Current path
      strPath = CurrentProject. Path & "\Adhoc_Report. xls"
      ' New workbook object
      Dim sh As Workbook
      DoCmd.OutputTo acOutputTable, "test2", acFormatXLS, strPath, 1
      ' This gives the above error:
      ' DoCmd.OutputTo acTable, "test2", "MicrosoftExcel Biff5(*.xls)", "strPath", 1

      ' Setting obj
      Set sh = CreateObject(st rPath)
      sh.ActiveSheet. Cells.ColumnWid th = 23
      sh.ActiveSheet. Cells.EntireRow .AutoFit

      Shaq

      Comment

      • Shakss2
        New Member
        • Dec 2007
        • 19

        #4
        Sorry for the previous post...

        It was my mistake...
        That seem to work but it is still using the old version 5.
        How can i force it to use version 7 or 8...

        Below is the complete code:
        Dim strPath As String
        ' Current path
        strPath = CurrentProject. Path & "\Adhoc_Report. xls"
        ' New workbook object
        Dim sh As Workbook

        DoCmd.OutputTo acTable, "test2", "MicrosoftExcel Biff5(*.xls)", "strPath", 1

        ' Setting obj
        Set sh = CreateObject(st rPath)
        sh.ActiveSheet. Cells.ColumnWid th = 23
        sh.ActiveSheet. Cells.EntireRow .AutoFit

        Shaq

        Comment

        • Shakss2
          New Member
          • Dec 2007
          • 19

          #5
          I also tried:
          DoCmd.OutputTo acTable, "test2", "MicrosoftExcel Biff8(*.xls)", "strPath", 1
          But it is still using version 5

          Shaq

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Originally posted by Shakss2
            I also tried:
            DoCmd.OutputTo acTable, "test2", "MicrosoftExcel Biff8(*.xls)", "strPath", 1
            But it is still using version 5

            Shaq
            'I see no reason why this shouldn't work:
            [CODE=vb]DoCmd.OutputTo acTable, "Test2", "MicrosoftExcel Biff8(*.xls)", strPath, 1[/CODE]

            Comment

            • Shakss2
              New Member
              • Dec 2007
              • 19

              #7
              Hi...

              I did this...n it worked...
              DoCmd.OutputTo acTable, "test2", acSpreadsheetTy peExcel9, "strPath", 1

              Thanks a lot for ur support

              Shaq

              Comment

              Working...