If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP - Writing to Excel Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-08-04, 14:30
robg69 robg69 is offline
Registered User
 
Join Date: Jul 2003
Posts: 21
ASP - Writing to Excel Problem

Ok, so I have an excel file on my webserver and I want to write
certain data to it. I'm using ASP, VBScript and IIS on a W2k Server.

Here are my steps:
1) Copy file "A" from a directory to directory B as "A1".
2) Open file "A1" and write data to certain cells.
3) Close Excel file.

The main problem is, it copies the file, writes the data, BUT
it makes two files... file "A1" which is the one I want and
another file "8B18300" or any other random name. WHY does it
make this other file? Is it the way I'm using the excel.Application
object? Also, sometimes, the data doesn't get written to my file
"A1", but if I open the randomly named file, the data is there.

SO, 2 questions:
1) why does it create this random file?
2) why does the data always get written to the random file,
and not my written file?

Thanks for any help, my basic code is included below:




I used the following code:

----------- BEGIN CODE -----------

dim objFSO, objExcel, objWorkBook, src, dest

Set objFSO = Server.CreateObject("scripting.filesystemobject")
objFSO.copyfile src, dest

set objExcel = CreateObject("Excel.Application")

objExcel.Visible = false
objExcel.DisplayAlerts = false

objExcel.Workbooks.Open(dest)

objExcel.ActiveSheet.Range("C3").Value = "HI"

objExcel.ActiveSheet.Range("E1:E1").Value = "Name"
objExcel.ActiveSheet.Range("F1:F1").Value = "Desc"

objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Workbooks.Close

objExcel.Quit
set objExcel = Nothing
Set objFSO = Nothing

----------- END CODE -----------

Last edited by robg69; 04-08-04 at 20:22.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On