Closed Thread
Results 1 to 2 of 2

OLEDB Connection in

  1. #1
    Registered User
    Join Date
    07-08-2009
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    3

    OLEDB Connection in

    Hi All;

    I am created a excel sheet in excel 2003 in which we import another excel sheet. for this I use OLEDB connection. And the entire code written inside the Macro is given below;



    Sub san()
    NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", Title:="Please select a file")
    Cells.Select
    Selection.ClearContents
    On Error GoTo x
    Selection.QueryTable.Delete
    x:

    With ActiveSheet.QueryTables.Add(Connection:=Array( _
    "OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" & NewFN & ";Mode=Share Deny Writ" _
    , _
    "e;Extended Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLED" _
    , _
    "B:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet " _
    , _
    "OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Loca" _
    , _
    "le on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
    ), Destination:=Range("A1"))
    .CommandType = xlCmdTable
    .CommandText = Array("Database")
    .Name = NewFN
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = True
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .PreserveColumnInfo = True
    .SourceDataFile = NewFN
    .Refresh BackgroundQuery:=True
    End With
    End Sub



    When ever I want to run the same Macro in excel2007 it is not possible.

    I think there is a problem in connection So ijust modified it as;



    Provider=Microsoft.Jet.OLEDB.4.0; <===> Provider=Microsoft.ACE.OLEDB.12.0;



    So please help me to solve this problem......

    Thank you

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: OLEDB Connection in

    mishra.ananda - again not following the forum rules I'm afraid...

    1 - this is a duplicate post (I already set this thread up for you yesterday when you posted it into someone else's thread)

    2 - as I mentioned previously you have not added code tags

    should you post further without adhering to the forum rules you will be banned.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1