Share via

Code Opens Older Version of Excel

Anonymous
2015-01-23T20:45:54+00:00

I have the following code to open a new Excel workbook but it always opens 2003 when I am wanting to use 2010. I realize this is probably due to the fact I am using 2010 but my default version is 2003. Removing 2003 from my PC is not an option and my IT has not been able to set 2010 as the default (they don't know why). Is there a way to change the following code to make it start up 2010 please? Thanks in advance.          

Sub Export_to_excel()

                    On Error GoTo err

                    Dim xlApp As New Excel.Application

                    Dim xlWB As New Workbook

                    Set xlWB = xlApp.Workbooks.Add

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

OssieMac 48,001 Reputation points Volunteer Moderator
2015-01-25T07:13:51+00:00

Try the following. Note the variables dimensioned as Objects.  (not New)

Sub Export_to_excel()

    Dim xlApp As Object

    Dim xlWB As Object

    Set xlApp = CreateObject("Excel.Application.14")

    xlApp.Visible = True

    Set xlWB = xlApp.Workbooks.Add

End Sub

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2015-01-25T07:41:49+00:00

    Try the following. Note the variables dimensioned as Objects.  (not New)

    Sub Export_to_excel()

       

        Dim xlApp As Object

        Dim xlWB As Object

       

        Set xlApp = CreateObject("Excel.Application.14")

       

        xlApp.Visible = True

       

        Set xlWB = xlApp.Workbooks.Add

       

    End Sub

    Excellent! Works like a charm. Thanks very much.

    Was this answer helpful?

    0 comments No comments