Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 589867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:28:07+00:00 2026-05-13T15:28:07+00:00

I am working with the Microsoft OLE DB Provider for Jet to execute queries

  • 0

I am working with the Microsoft OLE DB Provider for Jet to execute queries on spreadsheets in Excel using VBA. Is there a way to execute the following code on an unsaved workbook?

For example, ActiveWorkbook.FullName returns “Book1” if the workbook has never been saved. In that case the Data Source will assume the path is the active directory, and error out because the file was never saved.

Is there any way to use the Excel temporary file as the Data Source for Jet? I would like to test this but I don’t even know how to return the Path and Name for the Excel temporary file.

Public Sub LocalJetQuery()

    Dim objStartingRange As Range
    Dim objConnection As New ADODB.Connection
    Dim objRecordset As New ADODB.Recordset

    Dim strDSN As String
    Dim strSQL As String

    Set objStartingRange = Application.Selection

    If CLng(Application.Version) >= 12 Then
        strDSN = "Provider=Microsoft.ACE.OLEDB.12.0;" _
        & "Data Source=" & objStartingRange.Worksheet.Parent.FullName & ";" _
        & "Extended Properties=""Excel 12.0 Xml;HDR=No;IMEX=1"";"
    Else
        strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source=" & objStartingRange.Worksheet.Parent.FullName & ";" _
        & "Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";"
    End If

    strSQL = "SELECT * FROM [" & objStartingRange.Worksheet.Name & "$];"

    objConnection.Open strDSN
    objRecordset.Open strSQL, objConnection

    Application.Workbooks.Add(xlWBATWorksheet).Sheets(1).Cells(1, 1).CopyFromRecordset objRecordset

End Sub

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:28:07+00:00Added an answer on May 13, 2026 at 3:28 pm

    No. Just like David Fenton says in the comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with the following code published on msdn: http://msdn.microsoft.com/en-us/library/fx6588te.aspx I understand
I am trying to find a way to decode the REG_BINARY value for HKLM\Software\Microsoft\Ole\DefaultLaunchPermission
I am using Microsoft Unity 2.0 and the interception extension is not working as
I am working with Microsoft SQL Server 2005, and when I execute this query:
Recently working on Speech using microsoft translate. Just wonder if I can request by
I am working with a database hosted at GoDaddy using Microsoft SQL Server Management
I'm working on collision detection for a game written using the Microsoft XNA framework
Working with Microsoft SQL Server I found extremely useful SQL Server Profiler and Estimated
So I'm getting a new job working with databases (Microsoft SQL Server to be
I'm working on customizing a Microsoft Dynamics CRM (4.0) system for my university as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.