Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Creating new Excel Application problem

Hi,
Before this code is run, I have two workbooks open (One where all
the code and forms are, and the other is just a database of
information). I am trying to create a report from my application using
a template (.xlt file) I created. The code below is just a test to see
if my copying and pasting between two Excel application objects is
working, but it isn't. On the set tempRow = ... I keep getting a Run
Time error 1004 "application-defined or object-defined error"

Anyone got any idea how to fix it?

Thanks

Dim currTemplate As String
currTemplate = MyPath & BACKSLASH & templateContainer & BACKSLASH &
Template1

Set tempApp = CreateObject("Excel.Application")
Set tempWB = tempApp.Workbooks.add(currTemplate)
Set tempWS = tempWB.Sheets(1)

tempApp.Visible = True

For i = 3 To 10
'db.Worksheets("dbdata").Select
Set foundRow = db.Worksheets("dbdata").Range(Cells(i, 1),
Cells(i, 5))
Set tempRow = tempWB.Worksheets(1).Range(Cells(i, 1), Cells(i,
5))
Debug.Print foundRow.Address
Debug.Print tempRow.Address
foundRow.Copy
tempRow.PasteSpecial
Next i

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Creating new Excel Application problem

FYI, I didn't copy the part where I do dim foundrow and temprow as
ranges

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Creating new Excel Application problem

The problem with this is that Cells is unmodified so it refers to the active
sheet. It would work only if the worksheet is active.

Set tempRow = tempWB.Worksheets(1).Range(Cells(i, 1), Cells(i, 5))

Instead try this:

I'll use tempWS since you do create it:

With tempWS
Set tempRow = .Range(.Cells(i, 1), .Cells(i, 5))
End With

--
Jim
"Rishi Dhupar" wrote in message
ups.com...
| Hi,
| Before this code is run, I have two workbooks open (One where all
| the code and forms are, and the other is just a database of
| information). I am trying to create a report from my application using
| a template (.xlt file) I created. The code below is just a test to see
| if my copying and pasting between two Excel application objects is
| working, but it isn't. On the set tempRow = ... I keep getting a Run
| Time error 1004 "application-defined or object-defined error"
|
| Anyone got any idea how to fix it?
|
| Thanks
|
| Dim currTemplate As String
| currTemplate = MyPath & BACKSLASH & templateContainer & BACKSLASH &
| Template1
|
| Set tempApp = CreateObject("Excel.Application")
| Set tempWB = tempApp.Workbooks.add(currTemplate)
| Set tempWS = tempWB.Sheets(1)
|
| tempApp.Visible = True
|
| For i = 3 To 10
| 'db.Worksheets("dbdata").Select
| Set foundRow = db.Worksheets("dbdata").Range(Cells(i, 1),
| Cells(i, 5))
| Set tempRow = tempWB.Worksheets(1).Range(Cells(i, 1), Cells(i,
| 5))
| Debug.Print foundRow.Address
| Debug.Print tempRow.Address
| foundRow.Copy
| tempRow.PasteSpecial
| Next i
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Creating new Excel Application problem

Brillaint. Never would have thought of that.

thanks a lot.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a freeware application for creating gant charts in excel Bryant Charts and Charting in Excel 1 September 16th 05 08:16 PM
Creating an private Excel.Application Chet Cromer Excel Programming 2 May 27th 04 08:57 PM
Problem quitting excel when it is used by ASP.NET application Tom Excel Programming 0 May 10th 04 08:35 PM
Problem on the ASP using the Excel.Application Object David Huang Excel Programming 0 April 23rd 04 02:07 AM
Problem with closing the excel application guhan Excel Programming 1 August 20th 03 01:56 PM


All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"