|
-
Oct 25th, 2005, 11:48 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Writing to Excel
Hi guys -
I got the following from vb5 help:
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True
ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"
I get an error on the last line: "Object doesn't support this property or method." What's wrong?
Please help.
-
Oct 25th, 2005, 11:53 PM
#2
Re: Writing to Excel
Exactly which version of the Excel control do you have referenced?
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Oct 25th, 2005, 11:54 PM
#3
Re: Writing to Excel
Welcome to the Forums.
What version of Excel are you using? Do you need to support different versions of Excel?
This will work.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim oApp As Object
Dim oWB As Object
Dim oSht As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
Set oWB = oApp.Workbooks.Add
Set oSht = oWB.Sheets("Sheet1")
oSht.Cells(1, 1).Value = "This is column A, row 1"
oWB.Close SaveChanges:=True, FileName:="C:\Book1.xls"
Set oSht = Nothing
Set oWB = Nothing
oApp.Quit
Set oApp = Nothing
End Sub
Moved from Classic VB forum.
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 
-
Oct 26th, 2005, 12:23 AM
#4
Thread Starter
Addicted Member
Re: Writing to Excel
Thanks! That was quick - and it worked!
FYI, I am using Access 97 and have the Excel 8.0 Reference installed in vb5 Pro.
Salud!
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
|