Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default application or object defined error on print to file

In another sub, this works just fine! The only difference is that I have it
select a different sheet and do the same thing.

This is failing on : Print #3, Trim(Cells(l, 1)) 'sample id
saying that there is an application-defined or object-defined error.
Sometimes it says the file is already open.

OK Here's my code:

Public Sub cations()
Dim l, m, n As Integer

Sheets("cations").Select


Open "c:\textfiles\postmcrocations.txt" For Output As #3
Open "c:\textfiles\temp\postmcrocations.tmp" For Output As #4



For l = Cells(2, 17) To Cells(2, 18)
'header info
Print #3, Trim(Cells(l, 1)) 'sample id
Print #4, Trim(Cells(l, 1))

Print #1, "$cations" 'multicomponent
Print #1, "6" 'number of analytes
For m = 2 To 7
n = m + 7
Print #1, Trim(Cells(1, m)) 'analyte name
Print #1, Trim(Cells(l, m)) 'analyte value
Print #1, Trim(Cells(l, n)) 'chromatagram location for
secondary result)
Next m


Next l

Close #3
Close #4

End Sub


Thanks!

Jesse
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default application or object defined error on print to file

Sorry, I found my error. On using a different sheet, the number of field
values changed. On:
For l = Cells(2, 17) To Cells(2, 18), 17 should have been 16 and 18 should
have been 17.

Thanks anyway!

Jesse

"cutthroatjess" wrote:

In another sub, this works just fine! The only difference is that I have it
select a different sheet and do the same thing.

This is failing on : Print #3, Trim(Cells(l, 1)) 'sample id
saying that there is an application-defined or object-defined error.
Sometimes it says the file is already open.

OK Here's my code:

Public Sub cations()
Dim l, m, n As Integer

Sheets("cations").Select


Open "c:\textfiles\postmcrocations.txt" For Output As #3
Open "c:\textfiles\temp\postmcrocations.tmp" For Output As #4



For l = Cells(2, 17) To Cells(2, 18)
'header info
Print #3, Trim(Cells(l, 1)) 'sample id
Print #4, Trim(Cells(l, 1))

Print #1, "$cations" 'multicomponent
Print #1, "6" 'number of analytes
For m = 2 To 7
n = m + 7
Print #1, Trim(Cells(1, m)) 'analyte name
Print #1, Trim(Cells(l, m)) 'analyte value
Print #1, Trim(Cells(l, n)) 'chromatagram location for
secondary result)
Next m


Next l

Close #3
Close #4

End Sub


Thanks!

Jesse

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
Export a chart in a GIF file. Run-time error '1004': Application-defined or object-defined error; [email protected] Excel Programming 4 September 16th 07 11:09 PM
Copying A Range of Cells From one Sheet to Another - Error Application Defined or Object Defined Matt[_39_] Excel Programming 3 July 25th 06 01:13 AM
Runtime error 1004- application defined or object defined erro Jim Thomlinson[_5_] Excel Programming 0 February 6th 06 09:29 PM
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error -[::::Shamran::::]- Excel Programming 7 June 7th 05 02:14 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


All times are GMT +1. The time now is 04:10 PM.

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

About Us

"It's about Microsoft Excel"