473,748 Members | 2,223 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 1641
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
4035
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
3064
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
3181
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
3918
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
18572
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
3184
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
3176
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
5326
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
1270
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
8983
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9359
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
9310
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
9236
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
6792
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
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3298
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
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
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.