Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import macro

What I'm trying to do is creat a macro that will acess the information
form another excel file but i would like it to axcess a file of my
choesing not a designated one because the file will change locations
and names on different computers
i used the record a macro to start this one but now i'm stuck

I apperciate the help

Greg


Sub Import_List()
'
'to import the active crew list from another excel file
'
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User
ID=Admin;Data Source=C:\Documents and Settings\Greg\Desktop\ILO
List.xls;Mode=" _
, _
"Share Deny Write;Extended Properties=""HDR=YES;"";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Passw" _
, _
"ord="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking
Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Tran"
_
, _
"sactions=1;Jet OLEDB:New Database Password="""";Jet
OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet
OLEDB:" _
, _
"Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without
Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("AE6"))
.CommandType = xlCmdTable
.CommandText = Array("'ILO List$'")
.Name = "ILO List 'ILO List$'"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceConnectionFile = _
"C:\Documents and Settings\Greg\My Documents\My Data
Sources\ILO List 'ILO List$'.odc"
.SourceDataFile = "C:\Documents and Settings\Greg\Desktop\ILO
List.xls"
.Refresh BackgroundQuery:=False
Range("B6").Select
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
ADG ADG is offline
external usenet poster
 
Posts: 76
Default Import macro

Hi Gregers

Try adding the below to the start of you code

Dim fileToOpen As Variant
Do While fileToOpen = ""
fileToOpen = Application.GetOpenFilename("Excel Workbooks (*.xls), *.xls")
Loop

this will let you select a filename and path

the change your code above to use the filename e.g.

"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User ID=Admin;Data
Source=" & fileToOpen & ";Mode=" _

--
Tony Green


" wrote:

What I'm trying to do is creat a macro that will acess the information
form another excel file but i would like it to axcess a file of my
choesing not a designated one because the file will change locations
and names on different computers
i used the record a macro to start this one but now i'm stuck

I apperciate the help

Greg


Sub Import_List()
'
'to import the active crew list from another excel file
'
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User
ID=Admin;Data Source=C:\Documents and Settings\Greg\Desktop\ILO
List.xls;Mode=" _
, _
"Share Deny Write;Extended Properties=""HDR=YES;"";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Passw" _
, _
"ord="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking
Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Tran"
_
, _
"sactions=1;Jet OLEDB:New Database Password="""";Jet
OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet
OLEDB:" _
, _
"Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without
Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("AE6"))
.CommandType = xlCmdTable
.CommandText = Array("'ILO List$'")
.Name = "ILO List 'ILO List$'"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceConnectionFile = _
"C:\Documents and Settings\Greg\My Documents\My Data
Sources\ILO List 'ILO List$'.odc"
.SourceDataFile = "C:\Documents and Settings\Greg\Desktop\ILO
List.xls"
.Refresh BackgroundQuery:=False
Range("B6").Select
End With


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import macro Gene Augustin Excel Discussion (Misc queries) 2 March 2nd 09 10:28 PM
Import Macro dannykuk Excel Programming 1 January 5th 06 03:20 AM
Import macro from another workbook by macro Ivica Excel Programming 1 May 4th 05 12:26 PM
Import and run Macro Steph[_3_] Excel Programming 3 September 28th 04 09:33 PM
Macro import Lynn[_2_] Excel Programming 3 August 7th 03 10:18 PM


All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"