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 July 12th, 2004, 11:54 AM
Registered User
 
Join Date: Jun 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Server exception error

I am writing a program that gets data and writes it to excel files. I am having trouble with a section of code that copies the formulas from three cells and pastes them to three cells directly below.

The problem is that if I have the excel file open prior to running the program, it completes with no problems. If I allow the program to open the file I get the following error:

runtime error '-2147417851 (80010105)'
  Automation error
  The server threw an exception

The file is on our plant LAN server on a shared drive.

The code that copies and pastes the cells is:

wkbStartData.Worksheets("Unit " & CStr(i + 1)).Range("R" & _
  CStr(CInt(txtWorkRow) - 1) & ":T" & CStr(CInt(txtWorkRow) - 1)).Copy

wkbStartData.Worksheets("Unit " & CStr(i + 1)).Range("R" & _
  txtWorkRow & ":T" & txtWorkRow).PasteSpecial Paste:=xlFormulas, _
  Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Any ideas or suggestions?

Thanks to all.

Thanks,

Ray
 
Old July 13th, 2004, 09:43 AM
Registered User
 
Join Date: Jun 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just thought I'd add my current solution. Since what I was looking for was to copy the formulas from three cells down a row, I changed the two lines of code to the following three lines. It appears to have solved the problem. I would still like to get any ideas as to why the other two lines of code get a server exception.

Thanks.

wkbStartData.Worksheets("Unit " & CStr(i + 1)).Range("R" & _
  txtWorkRow).Value = "=(E" & txtWorkRow & "*$E$2+F" & txtWorkRow _
  & "*$F$2+G" & txtWorkRow & "*$G$2+H" & txtWorkRow & "*$H$2+I" & _
  txtWorkRow & "*$I$2+J" & txtWorkRow & "*$J$2+K" & txtWorkRow _
  & "*$K$2)*IF(M" & txtWorkRow & ">0,P" & txtWorkRow & ",1)"

wkbStartData.Worksheets("Unit " & CStr(i + 1)).Range("S" & _
  txtWorkRow).Value = "=IF(M" & txtWorkRow & ">0,Q" & txtWorkRow_
   & "*(E" & txtWorkRow & "*$E$2+F" & txtWorkRow & "*$F$2+G" & _
   txtWorkRow & "*$G$2+H" & txtWorkRow & "*$H$2+I" & txtWorkRow _
   & "*$I$2+J" & txtWorkRow & "*$J$2+K" & txtWorkRow & "*$K$2),(E"_
   & txtWorkRow & "*$E$2+F" & txtWorkRow & "*$F$2+G" & txtWorkRow_
   & "*$G$2+H" & txtWorkRow & "*$H$2+I" & txtWorkRow & "*$I$2+J" &_
   txtWorkRow & "*$J$2+K" & txtWorkRow & "*$K$2))"

wkbStartData.Worksheets("Unit " & CStr(i + 1)).Range("T" & _
  txtWorkRow).Value = "=IF(R" & txtWorkRow & "=0,0,D" & txtWorkRow_
  & "/R" & txtWorkRow & ")"


Thanks,

Ray





Similar Threads
Thread Thread Starter Forum Replies Last Post
Security Exception Error nici ASP.NET 2.0 Basics 0 May 23rd, 2007 12:03 PM
[Urgent] Server Side custom exception tjacemy General .NET 3 April 3rd, 2007 07:44 AM
Exception error lewright Java Basics 8 July 17th, 2006 06:35 PM
Server Exception Error edray Pro VB 6 0 July 13th, 2004 09:01 AM
Exception Error aadz5 ASP.NET 1.0 and 1.1 Basics 1 November 14th, 2003 10:50 AM





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