Results 1 to 9 of 9

Search for and select and database to import to excel

Threaded View

chrismann85 Search for and select and... 05-19-2008, 04:24 AM
Andy Pope You can use the... 05-19-2008, 04:36 AM
chrismann85 Thanks Andy, I'm not sure... 05-19-2008, 04:51 AM
Andy Pope It would go at the top of... 05-19-2008, 04:59 AM
chrismann85 I'm still getting an error: ... 05-19-2008, 05:06 AM
  1. #1
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74

    Smile Search for and select and database to import to excel

    Hi all,

    I have a code which imports data from a certain database, see below:

    Sub Import_PPG()
    '
    ' Import_PPG Macro
    ' Macro recorded 24/01/2008 by Chris Mann
    '
    
    '
        Columns("A:U").Select
        Selection.Delete Shift:=xlToLeft
        Range("A1").Select
        With ActiveSheet.QueryTables.Add(Connection:=Array( _
            "OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\cmann29\My Documents\2007" _
            , _
            " Test Converter Tool\New WTB14768.mdb;Mode=ReadWrite;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path" _
            , _
            "="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;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:Encryp" _
            , _
            "t Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
            , ""), Destination:=Range("A1"))
            .CommandType = xlCmdTable
            .CommandText = Array("PPG")
            .Name = "New WTB14535"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .PreserveColumnInfo = True
            .SourceDataFile = _
            "C:\Documents and Settings\cmann29\Desktop\Chris Mann\2007 Test Converter Tool\New WTB14535.mdb"
            .Refresh BackgroundQuery:=False
        End With
    End Sub
    However, I want the user to be able to specify the database using an input box, or a combo-box or something similar. I know its possible but I'm a little stuck. Basically, I would like the user to only have to put in the name of the database (as they will all be in the same folder).

    Any Ideas?

    *Apologies for the grammatical error in the title*
    Last edited by chrismann85; 05-19-2008 at 04:29 AM.

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