May 23rd, 2006, 12:17 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Import From Excel to Access
VB Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, WkSh, Path & SpNm, True, WkSh
I need to specify which sheets in a workbook need to be imported and it is not working. I am receieving an error saying object doenst exist. I have checked for spelling and syntax errors in the variables already, but it looks like the error is in the range section.
Thank you,
Swoozie
Somedays you just should not get out of bed.
May 23rd, 2006, 01:00 PM
#2
Re: Import From Excel to Access
Try...
VB Code:
Application.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "Table1", "C:\Book1.xls", False, "Sheet2$"
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 23rd, 2006, 01:10 PM
#3
Thread Starter
Hyperactive Member
Re: Import From Excel to Access
Originally Posted by
RobDog888
Try...
VB Code:
Application.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "Table1", "C:\Book1.xls", False, "Sheet2$"
I have attached the error. It works fine if you hand type the sheet name but using a variable it doenst work.
Thank you,
Swoozie
Attached Images
Swoozie
Somedays you just should not get out of bed.
May 23rd, 2006, 01:35 PM
#4
Re: Import From Excel to Access
It was just an example, did you change the parameters to your needs? do you have a "C:\Book1.xls" file? Thats probably the issues. change to reflect your needs.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 23rd, 2006, 01:42 PM
#5
Thread Starter
Hyperactive Member
Re: Import From Excel to Access
VB Code:
Application.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, WkSh, Path & SpNm, True, WkSh
WKsh = the worksheet name and the name I want the table that is being imported into.
path = the location of the excel spreadsheet
spnm = the name of the spreadsheet
The worksheets have headings, so I set that to "True"
All of it works except the passing of the worksheet tab name. And that makes no sense to me.
Swoozie
Somedays you just should not get out of bed.
May 23rd, 2006, 01:47 PM
#6
Re: Import From Excel to Access
You have your parameters wrong. See post #2 for the example.
You need to specify the Access Table name that your importing the spreadsheet into.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 23rd, 2006, 01:55 PM
#7
Thread Starter
Hyperactive Member
Re: Import From Excel to Access
I did, the table name is the same as the worksheet name. As I previously said, if I take out the last
VB Code:
Application.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel7, WkSh, Path & SpNm, True, WkSh
- Dosent Work
And switch it with this
VB Code:
Application.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel7, WkSh, Path & SpNm, True, "Facility" 'WkSh
It does work. But I can not have a hard keyed valule I have over 20 spreadsheets I need to import.
Swoozie
Somedays you just should not get out of bed.
May 23rd, 2006, 02:01 PM
#8
Re: Import From Excel to Access
Try replacing the varible value with...
"[Facility$]"
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 23rd, 2006, 02:08 PM
#9
Thread Starter
Hyperactive Member
Re: Import From Excel to Access
I have tried to replace it with
"Facility"
"[Facility]"
"[Facility$]"
Facility
"[Facility]$"
But none of that really matters because I need to use a variable and by all accounts this should work. I can not find a reason anywhere that this would not work.
Any other ideas on how to import other than the transferspreadsheet method?
Swoozie
Somedays you just should not get out of bed.
May 23rd, 2006, 02:12 PM
#10
Re: Import From Excel to Access
They are not hidden or protected sheets?
Weird error.
You could add a reference to Excel and use the excel object model to manually code an import procedure.
Or use ADO to query the spreadsheet and perform a INSERT INTO action query statement.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 24th, 2006, 12:31 PM
#11
Thread Starter
Hyperactive Member
Re: Import From Excel to Access
Originally Posted by
RobDog888
They are not hidden or protected sheets?
Weird error.
You could add a reference to Excel and use the excel object model to manually code an import procedure.
Or use ADO to query the spreadsheet and perform a INSERT INTO action query statement.
no the answer was really evident "!"
Application.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel7, WkSh, Path & SpNm, True, WkSh & "!"
Swoozie
Somedays you just should not get out of bed.
May 24th, 2006, 01:04 PM
#12
Re: [RESOLVED] Import From Excel to Access
Well I have only seen the exclamation point be used for identifying a procedure after a workbook file like this - C:\Test.xls!ImportMe
Usually the $ sign is for identifying sheets but as long as it works for you.
What version are you running anyways?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 24th, 2006, 01:17 PM
#13
Thread Starter
Hyperactive Member
Re: [RESOLVED] Import From Excel to Access
I actually found the answer somewhere in Microsoft Help (cant find it again) I was going to copy the reference for you but I can not locate it.
It was in a very obscure place and had nothing to do with what I looked up, it was just shown as an example for something so I thought I would try it.
We are using MS Office 2002 on Window Prof 2000
Swoozie
Somedays you just should not get out of bed.
May 24th, 2006, 01:21 PM
#14
Re: [RESOLVED] Import From Excel to Access
Ok, thanks. I'll keep my eyes peeled for it whenever I am in the help file.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width