Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default HELP with Syntax please !

The following code I recorded to import data from a closed workbook
("lala.xls") into the active sheet.

As I'm trying to import data from multiple closed workbooks, I need to
make the filename "lala.xls" and its folder path, variables.

But try as I might, I cannot make it work - it keeps complaining "Type
mismatch" or the second last line ( .Refresh BackgroundQuery:=False).

Appreciate your help. Thanks.

AP

----------------

With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User
ID=Admin;Data Source=P:\BUSINESS SYSTEMS\RECORDS\FIELD REPORTS
\lala.xls;Mode=S" _
, _
"hare Deny Write;Extended Properties=""HDR=YES;"";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Passwo" _
, _
"rd="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking
Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Trans" _
, _
"actions=1;Jet OLEDB:New Database Password="""";Jet
OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:D" _
, _
"on't Copy Locale on Compact=False;Jet OLEDB:Compact Without
Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("Summary$")
.Name = "lala"
.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 = "P:\BUSINESS SYSTEMS\RECORDS\FIELD REPORTS
\lala.xls"
.Refresh BackgroundQuery:=False
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default HELP with Syntax please !

This should get you started

sPath = "P:\BUSINESS SYSTEMS\RECORDS\FIELD REPORTS\"
sFilename = "lala.xls"

With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User
ID=Admin;Data Source=" & spath & sFilename & ";Mode=S" _


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
ups.com...
The following code I recorded to import data from a closed workbook
("lala.xls") into the active sheet.

As I'm trying to import data from multiple closed workbooks, I need to
make the filename "lala.xls" and its folder path, variables.

But try as I might, I cannot make it work - it keeps complaining "Type
mismatch" or the second last line ( .Refresh BackgroundQuery:=False).

Appreciate your help. Thanks.

AP

----------------

With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=" """;User
ID=Admin;Data Source=P:\BUSINESS SYSTEMS\RECORDS\FIELD REPORTS
\lala.xls;Mode=S" _
, _
"hare Deny Write;Extended Properties=""HDR=YES;"";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Passwo" _
, _
"rd="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking
Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Trans" _
, _
"actions=1;Jet OLEDB:New Database Password="""";Jet
OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:D" _
, _
"on't Copy Locale on Compact=False;Jet OLEDB:Compact Without
Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("Summary$")
.Name = "lala"
.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 = "P:\BUSINESS SYSTEMS\RECORDS\FIELD REPORTS
\lala.xls"
.Refresh BackgroundQuery:=False
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
right syntax pls123 Excel Worksheet Functions 8 May 6th 10 05:18 AM
VB Syntax dhstein Excel Discussion (Misc queries) 6 November 8th 08 09:13 PM
Syntax help for if Dean[_8_] Excel Programming 2 November 1st 06 07:43 PM
If then syntax RL Excel Worksheet Functions 3 June 22nd 05 05:30 AM
syntax help Blue Excel Programming 3 September 29th 04 11:51 PM


All times are GMT +1. The time now is 04:05 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"