Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro 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 September 19th, 2003, 02:02 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem while saving the excel sheet

Private Sub createAndSaveExcelSheet(ByRef lRS As ADODB.Recordset, lDate As Date, ByRef lXLapp As Excel.Application)
    Dim lXLwb As Excel.Workbook
    Dim lXLws As Excel.Worksheet
    Dim fso As New FileSystemObject
    Dim lICount As Integer
    Set lXLapp = New Excel.Application
    lXLapp.Visible = False
    Set lXLwb = lXLapp.Workbooks.Add
    Set lXLws = lXLwb.ActiveSheet
    lXLws.Rows(6).CopyFromRecordset lRS
    Dim intcol As Integer
    MsgBox "excel sheet open"
    lXLws.Cells(5, 1) = "Card No"
    lXLws.Cells(5, 2) = "Name"
    lXLws.Cells(5, 3) = "Emp Code"
    lXLws.Cells(5, 4) = "Department"
    For intcol = 1 To 5
        lXLws.Cells(5, intcol).Font.Size = 12
        lXLws.Cells(5, intcol).Font.Bold = True
    Next
    MsgBox "doing autofit"
    For lICount = 1 To lRS.Fields.count
        lXLws.Columns.AutoFit
    Next lICount
    MsgBox "autofit done"
    lXLws.Cells(1, 1).Font.Size = 18
    lXLws.Cells(1, 1) = "SWIPE CARD REPORT GENERATED ON " & VBA.Date & " at " & VBA.Time
    lXLws.Cells(3, 1).Font.Size = 16
    lXLws.Cells(3, 1) = "People absent on " & lDate
    MsgBox "parent stuff"
    lXLapp.Parent.Windows(lXLwb.Name).Visible = True
    MsgBox "switch off alerts to avoid overwrite dialog box by the excel application"
    'switch off alerts to avoid overwrite dialog box by the excel application
    lXLapp.DisplayAlerts = False
    MsgBox "alert off and saving now"
--> lXLwb.SaveAs (App.Path & "\" & VBA.Format(lDate, "mmddyyyy"))
    lXLapp.DisplayAlerts = True
    lXLwb.Close
    Set lXLwb = Nothing
    Set lXLws = Nothing
    Set lXLapp = Nothing
    MsgBox "create and save excel done"
End Sub

all the code is working fine till the msgbox" alert off and saving now"
the problem is coming while i try to save the excel sheet. i have marked with an arrow. this error is coming i=on the pc where vb is not installed.
please help me to overcome this error.
 
Old September 19th, 2003, 08:04 AM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried to Save the worksheet you are working with, instead of the workbook? ex: lXLwb.SaveAs fileName
 
Old September 19th, 2003, 08:05 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does the machine have the VB runtime dlls on it (MSVBVM60.DLL, VBST6Kit.dll)? Thats what the issue looks like.

Yehuda
 
Old September 20th, 2003, 01:33 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi bitner : i tried it already but no change..error at same position

hi yehuda : tried by copying the dll's.. but no change..





Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL SHEET SECURITY kotaiah Excel VBA 1 February 21st, 2013 08:45 AM
How to position to a specific sheet before saving pkipe Excel VBA 1 December 17th, 2007 10:36 PM
ListBox in Excel Sheet anup.bihani Excel VBA 1 November 16th, 2006 10:29 AM
write multi-sheet Excel w/o Excel.Application manmoth Classic ASP Components 2 November 22nd, 2005 10:56 AM
EXCEL question saving a file saving the the first macupryk VS.NET 2002/2003 0 January 6th, 2005 05:33 PM





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