|
-
Nov 10th, 2005, 06:13 PM
#1
Thread Starter
Addicted Member
ADO EXCEL problem 2
hi all,
how can I programatically adjust width of column (on excel sheet) to the "width" of data that I am pasting into a row. to insert data I am using ado.
thx in advance for your help
regards,
sweet_dreams
-
Nov 10th, 2005, 06:22 PM
#2
Re: ADO EXCEL problem 2
If you are using ADO, you cannot control formatting in any manner whatsoever. You will need to use Automation to be able to set formatting.
-
Nov 11th, 2005, 09:11 AM
#3
Re: ADO EXCEL problem 2
Use the following code snippet to auto adjust the width of column "A".
VB Code:
Worksheets("Sheet1").Range("A1").Columns.AutoFit
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Nov 12th, 2005, 04:42 PM
#4
Thread Starter
Addicted Member
Re: ADO EXCEL problem 2
Hi DKenny,
Unfortunatelly when I write the code that you advised me I get such an error:
Run-time error 9
Subscript out of range
What should I do then???
Please help,
Regards
sweet_dreams
-
Nov 12th, 2005, 04:50 PM
#5
Re: ADO EXCEL problem 2
Why paste it in when you are using ADO if you add the use of the Excel Object Model?. Like DKenny posted but change "Sheet1" to whatever your sheets name is. This is why your getting the subscript out of range error - 9.
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 
-
Nov 12th, 2005, 04:52 PM
#6
Thread Starter
Addicted Member
Re: ADO EXCEL problem 2
RobDog888,
the problem is that I've changed the sheet name
-
Nov 12th, 2005, 04:53 PM
#7
Re: ADO EXCEL problem 2
Changed via during your ode execution or manually? Just change "Sheet1" to whatever your new sheet name is now.
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 
-
Nov 12th, 2005, 04:59 PM
#8
Thread Starter
Addicted Member
Re: ADO EXCEL problem 2
RobDog888,
As I have stated I changed sheet name for the name that exists in my workbook, to which sheet I want this code refer to.
-
Nov 12th, 2005, 05:08 PM
#9
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 
-
Nov 12th, 2005, 05:26 PM
#10
Thread Starter
Addicted Member
Re: ADO EXCEL problem 2
no, after changing the name I get the same error message
-
Nov 12th, 2005, 05:29 PM
#11
Re: ADO EXCEL problem 2
Did you save the workbook and maybe close and reopen Excel.
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
|