Results 1 to 3 of 3

Thread: [RESOLVED] nHelp excel.saveas to older version

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2024
    Posts
    2

    Resolved [RESOLVED] nHelp excel.saveas to older version

    This is a class i am writing for autocad. For legacy reasons, I need to save the excel file as an older format. I cannot figure it out. The program below runs fine if I leave off any version info and just use extension ".xls". But when I open in excel, it screams about being saved in different version than extension.

    Code:
    Imports System.IO
    
    Public Class Test3
        Public Sub Test3()
                ''---------------------------------------------------------------------starts export to excel
                Try
                    Dim Excel As Object = CreateObject("Excel.Application")
                    With Excel
                        .SheetsInNewWorkbook = 1
                        .Workbooks.Add()
                        .Worksheets(1).Select()
    
                        ''Data input here
    
                        .Application.DisplayAlerts = False
                        .ActiveCell.Worksheet.SaveAs(FileName:="12345.xls")
                        .Workbooks.Close()
                    End With
                Catch ex As Exception
                End Try
        End Sub
    End Class

    I tried: .ActiveCell.Worksheet.SaveAs(FileName:=XlsDefaultDir + "30" + DwgNo + ".xls", FileFormat:=XlFileFormat.xlExcel9795), this code causes error. (I did add ref and imports to interop)
    It causes an error when ran.

    Thanks in advance for any help.
    Last edited by dday9; Apr 4th, 2024 at 11:19 AM.

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,404

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2024
    Posts
    2

    Re: nHelp excel.saveas to older version

    I figured a solution. I was trying to use format code 43, I changed it to 18 and now it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width