LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Importing data from excel to excel

Hi All,

I'm trying to import data from a closed excel wkbk to an open excel wkbk. I
recorded the macro, made some adjustments, and sometimes it works, but most
the time it does not. Not sure where my problem(s) are, and I'm hoping that
you can help me. This is what I wrote/recorded:

'<<< ipath is the entire file path to the exported IMARC file
Dim ipath As String
ipath = Worksheets("mp").Range("i2")
'<<< iname is the name of the file
Dim iname As String
iname = Worksheets("mp").Range("j2")
'<<< noxls is the name of the file without the file extenstion
Dim noxls As String
noxls = Worksheets("mp").Range("j4")
'<<< fpath is the folder path to the IMARC folder
Dim fpath As String
fpath = Worksheets("mp").Range("k2")

Sheets("DI_Temp").Select
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User
ID=Admin;Data Source=" _
& iname & ";Mode=Share Deny Write;Extended
Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry
Path="""";Jet OLEDB", _
":Database Password="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database
Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:G" _
, _
"lobal Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet
OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=F" _
, _
"alse;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(noxls & "$")
.Name = noxls
.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 = ipath
.Refresh BackgroundQuery:=False
End With

The debug error always goes to ".Refresh BackgroundQuery:=False"
I've also experimented with switching to True, but get the same error.

Other details. In my network, each of us have a username with a period that
separates the first and last name. So a file/folder path would be something
like C:\Documents and Settings\john.doe\My Documents. I've read that the
period might be the issue, but it doesn't explain why it works sometimes.

Thank you.
 
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
Importing data from Excel worksheet into Excel template Mas[_3_] Excel Discussion (Misc queries) 2 August 14th 11 11:15 AM
Importing data into Excel mwy Excel Discussion (Misc queries) 0 June 12th 08 09:17 PM
Importing data from excel. dave Excel Discussion (Misc queries) 1 December 5th 07 05:01 PM
Importing data into excel SGT Buckeye Excel Worksheet Functions 3 April 14th 06 01:52 AM
Importing Excel data Grace[_3_] Excel Programming 1 February 26th 04 03:39 PM


All times are GMT +1. The time now is 09:42 PM.

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

About Us

"It's about Microsoft Excel"