473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to create excel sheet in Visual Basic 6.0 and send it as attachment

2
Hi,

Am using Visual BNasic 6.0,i have to generate an excel sheet when the user clicks on a button and send this file as an attachment to the receiver.......can i overwrite the same file again or will have to create a new file every time ??....is this possible???.............orelse is there any other way..................I have created the excel sheet but get an error when i sent it as attachment.........plz help me in the same.....its really very urgent..................

Thanking in Anticipation
Neelam
Aug 25 '05 #1
8 61576
pellem
3
It depends on how the file is created, but you can certainly open it, make changes, then save and close it, rather than re-creating it each time.

Also, how are you emailing it - Outlook VBA automation?
Sep 21 '05 #2
neelam
2
Thanx for the reply....i cudnt get the excel sheet creation...i wanted to kill the previous file and recreate a new one by the same name..is it possible.cudnt get help from anywhere so had to create a PDF file..that was easy..........Ya i am using my Outlook Express to sent tht efile as attachment.
Sep 22 '05 #3
This is a little late I think...but you are able to delete the existing file and create a new one afterward....
Expand|Select|Wrap|Line Numbers
  1. kill("C:\path\file.xls")
This should work...replace "C:\path\file.xls" with the path of the excel file you want to delete
Thanx for the reply....i cudnt get the excel sheet creation...i wanted to kill the previous file and recreate a new one by the same name..is it possible.cudnt get help from anywhere so had to create a PDF file..that was easy..........Ya i am using my Outlook Express to sent tht efile as attachment.
Aug 15 '06 #4
creating excel or text file are very easy but what i understand is each time either you append data on an existing file or kill & re-generate the following
syntax may help you

Open "C:\Test.xls" for append as #1
print #1, "String" & your variable
close #1
for sending as an attachement then you have to Reference the MAPI controls
and have to have a function to send mail with this controls

Regards
Aug 31 '06 #5
You can try out this code

Dim AppXls As Excel.Application
Dim ObjWb As Excel.Workbook


Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add

ObjWb.Worksheets.Item("Sheet1").Range(“A1”).Value = “1”
‘ Range is The Cell Address
ObjWb.SaveAs ("C:\TestCreate.Xls")

ObjWb.Close (SaveChanges = False)
Nov 15 '06 #6
Hi deepu12


You can try out this code

Dim AppXls As Excel.Application
Dim ObjWb As Excel.Workbook


Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add

ObjWb.Worksheets.Item("Sheet1").Range(“A1”).Value = “1”
‘ Range is The Cell Address
ObjWb.SaveAs ("C:\TestCreate.Xls")

ObjWb.Close (SaveChanges = False)

while compiling above code it is giving error at
ObjWb.Worksheets.Item("Sheet1").Range(“A1”).Value = “1”
that application defined or object defined error.
I have added the referance of Microsoft Excel library 9.0
Jan 4 '07 #7
km2k
1
This happens because the workbooks collection is initially empty. See the updated example :

Dim AppXls As Excel.Application
Dim ObjWb As Excel.Workbook
Dim ObjWs As Excel.Worksheet

Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add

Set ObjWs = ObjWb.Worksheets.Add
ObjWs.Range("A1").Value = "1"


ObjWb.SaveAs ("C:\TestCreate.xls")

ObjWb.Close (SaveChanges = False)
Jun 28 '07 #8
veer
198 100+
hello expert
i am looking for the solution of generating excel sheet in vb6.0 and found this code but when i run this code it produces the error on line
"Set ObjWb = AppXls.Workbooks.Add "
the error is " Method Add of object workbook faild"
please send some idea



This happens because the workbooks collection is initially empty. See the updated example :

Dim AppXls As Excel.Application
Dim ObjWb As Excel.Workbook
Dim ObjWs As Excel.Worksheet

Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add

Set ObjWs = ObjWb.Worksheets.Add
ObjWs.Range("A1").Value = "1"


ObjWb.SaveAs ("C:\TestCreate.xls")

ObjWb.Close (SaveChanges = False)
Nov 23 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
0
by: I Decker | last post by:
Hi all, Hope this is the right group. I am writing a program in c# to open create an excel document, enter some data, save it and then email it as an attachment. I have successfully created...
5
by: mark | last post by:
I've been looking at working with Excel data. I understand the process of getting the data into a dataset and modifying it. It's one of simple beauty that is well documented. Now, I want to send...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
10
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
0
by: campeon | last post by:
Hello,, I don,t understand bery good the visual basic or excel i dowload a good time activities program from a web site the program is like a cronometer whit start button and stop button...
2
by: krissh | last post by:
I know How Excel sheet in php .But wat i want is how to create Multiple sheets in Excel . This is the code for creating one excel sheet <?php header('Content-type:application/ms-xls'); ...
1
by: sathish34 | last post by:
i cud get the excel sheet creation...i wanted to kill the previous file and recreate a new one by the same name..is it possible.cudnt get help from anywhere so kindly reply me request.send me coding...
2
by: RohitGBhagwat | last post by:
Hi, I am facing problem in ASP application where I am getting error message "Server object, ASP 0178 (0x80070005) The call to Server.CreateObject failed while checking permissions. Access is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.