473,698 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing Excel with Quotes in Name?

Hi,

I have 5 excel spreadsheets that are exported to me weekly.
At first, I could not get them to import. Then I did a File -> Save as and
noticed that the Filenames of the spreadsheets contained Quotes around
them - hence the problem.

Is there any way to remove those quotes prior to import (other than "Save
As")???

Thanks in advance!

Rusty
Nov 13 '05 #1
2 1638
Don't know if this is close to your situation, but here is something
that works for me - note: you need to make a reference to the Microsoft
Excel Object Library from a Standard Module Menu - Tool/References

Sub GetExcelData()
Dim MyPath As Variant, MyName As Variant, rng As Excel.Range
Dim xlObj As Excel.Applicati on, wkbk As Excel.Workbook
Dim sht As Excel.Worksheet , i As Integer, j As Integer

MyPath = "C:\yourExcelFi lesDir\"
MyName = Dir(MyPath & "*.xls") ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
If MyName = "Book1 And test's.xls" Then
Debug.Print MyName ' Display entry only if it
Set xlObj = CreateObject("E xcel.Applicatio n")
Set wkbk = xlObj.Workbooks .Open(MyPath & MyName)
Set sht = wkbk.Sheets("Sh eet1")
Set rng = sht.UsedRange
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Cou nt
Debug.Print rng(i, j);
Next
Debug.Print
Next
wkbk.Close
xlObj.Quit
Set wkbk = Nothing
Set xlObj = Nothing
End If
MyName = Dir ' Get next entry.
Loop
End Sub

You can replace the Debugs with DAO code to write the data to a table in
Excel.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
I meant a table in Access. Here is some sample DAO code to go with the
routine: Say you have 10 columns of data in Excel, your table would
have 10 fields.

Sub GetExcelData()
Dim MyPath As Variant, MyName As Variant, rng As Excel.Range
Dim xlObj As Excel.Applicati on, wkbk As Excel.Workbook
Dim sht As Excel.Worksheet , i As Integer, j As Integer
Dim rs As Recordset

Set rs = CurrentDb.OpenR ecordset("tblEx celData")
MyPath = "C:\yourExcelFi lesDir\"
MyName = Dir(MyPath & "*.xls") ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
If MyName = "Book1 And test's.xls" Then
Set xlObj = CreateObject("E xcel.Applicatio n")
Set wkbk = xlObj.Workbooks .Open(MyPath & MyName)
Set sht = wkbk.Sheets("Sh eet1")
Set rng = sht.UsedRange
For i = 1 To rng.Rows.Count
rs.Addnew
For j = 1 To rng.Columns.Cou nt
rs(j - 1) = rng(i, j)
Next
rs.Update
Next
wkbk.Close
xlObj.Quit
Set wkbk = Nothing
Set xlObj = Nothing
End If
MyName = Dir ' Get next entry.
Loop
End Sub

The routine now assumes you have a table called tblExcelData which would
have the same fields (and datatypes per field) as the Excel Columns.
Also, the Excel range object, rng starts counting at 1. The DAO
recordset object starts counting at 0, thus rs(j - 1) = rng(i, j) to get
the columns synchronized correctly between Excel and Access. Oh yeah,
notice that the title of the excel workbook in my example contains a
quote

"Book1 And test's.xls"

which is how you get inside the "If" statement in the loop.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4033
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then need to input this in an Access database, where I do a comparison with the Actual cost. The table “TblBudget” in Access is made of 4 fields, namely: (1) CostElement (2) CostCenter (3) Month (4) Amount$. At the moment this method is very cumbersome....
7
3061
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the correct cells within that worksheet. The Excel Book is made up of 12 worksheets named Jan-Dec. Each worksheet has columns labeled as each day of that month. Column 'A' is reserved for 19 rows named "room1 - room19". The data I am importing from the...
5
3178
by: dixie | last post by:
If I sent a user an empty database container - dB with no tables and I needed them to import their tables into it and one of their tables was a hidden table with the prefix Usys, is there any way in code I can get that table imported without them having to go to options and show hidden tables and then import it manually? dixie
9
3915
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. There is no further explanation. What are the kinds of things that make this happen? Thanks from an obvious rookie. Gordon
6
18567
by: Sam Johnson | last post by:
HI I tried to send the following SQL string to an open databse, to export a table into excel format: g.Connection = conn 'valid OleDBConnection and Command objects g.CommandText = "SELECT * INTO XLSTest IN 'C:\' 'Excel 8.0;' FROM Table1" g.ExecuteNonQuery()
2
3179
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
5
3174
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All districts have used the same excel template and populated the same 32 data fields (columns). I created one large excel file from all 49 files which gives me a master table of 60,000 or so records. I have tried to import this master table into access...
3
5324
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file has no problems, I've done it manually with the Import Spreadsheet wizard. The worksheet has 43 rows, and I import a named range defined as "=Sheet1!$C:$E". The import works, but I get a table with 64K rows, all but 43 being blank!
1
1267
by: BraveKnight | last post by:
Hello I am trying to import from a csv file using the ole jet engine. All seems to work fine. The issue I am having though is if someone has a single quote char in the title of the file eg matt's file.csv. or they have muliple periods in the file name eg Jim.File.csv The way I am doing it is - C#
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.