Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2006, 03:24 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default Excel Application

Hi All!!!!


        I am making excel file and i have to write the data on it, so want to call it throug function...
        My source is below...
Private Sub Command1_Click()
        Dim abc As File, wb As excel.Workbook, app1 As excel.Application, isexist As Double
        Private Sub Command1_Click()
           Set app1 = CreateObject("Excel.Application")
           Set wb = app1.Workbooks.Add
           Dim fsys As New Scripting.FileSystemObject

           ActiveWorkbook.Worksheets(1).Select
           ActiveWorkbook.Worksheets(1).Name = "Daily Sale Report"
           ActiveSheet.Cells(3, 3) = "CUSTOMER SALES REPORT AS ON '" & Date & "'"
           app1.Visible = True

    WriteSheet2
    Set abc = fsys.GetFile("c:\temp\sfc.xls")
    abc.Attributes = Normal
    fsys.DeleteFile ("c:\temp\sfc.xls")
    wb.SaveAs FileName:="C:\temp\sfc.xls", FileFormat:=xlNormal, CreateBackup:=True
    app1.ActiveWorkbook.Save
End Sub

Private Sub WriteSheet2()
    ActiveWorkbook.Worksheets.Add
    ActiveWorkbook.Worksheets(2).Select
    ActiveWorkbook.Worksheets(2).Name = "Sheet Two"
    ActiveSheet.Cells(3, 0) = "Sheet Two"
    ActiveSheet.Cells(3, 1) = "Sheet Two"
    ActiveSheet.Cells(3, 2) = "Sheet Two"
    ActiveSheet.Cells(3, 3) = "Sheet Two"
    ActiveSheet.Cells(3, 4) = "Sheet Two"
    ActiveSheet.Cells(3, 5) = "Sheet Two"
    ActiveSheet.Cells(3, 6) = "Sheet Two"
End Sub


           I am getting the error in BOLD expression
           when calling function how can i handle it give me some idea....

           Exception is - Runtime Error '1004':
                               Application-Defined or object defined Error.


           Thanks in Advance!!! :)


DPK..
__________________
DPK..
 
Old November 28th, 2006, 02:24 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Perhaps the cell is formatted in a way that will not accept text... (I'm only guessing.)
 
Old November 29th, 2006, 06:49 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Quote:
quote:Originally posted by BrianWren
 Perhaps the cell is formatted in a way that will not accept text... (I'm only guessing.)
Thanks to your reply....
:)

DPK..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Building an Excel like Application yuenli C# 2005 1 June 22nd, 2007 11:57 AM
write multi-sheet Excel w/o Excel.Application manmoth Classic ASP Components 2 November 22nd, 2005 10:56 AM
Setting a new Excel application Shasur Pro VB 6 1 September 21st, 2005 10:12 AM
Excel.Application whiteshark Classic ASP Components 1 September 4th, 2003 06:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.