Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Export a chart in a GIF file. Run-time error '1004': Application-defined or object-defined error; | Excel Programming | |||
Copying A Range of Cells From one Sheet to Another - Error Application Defined or Object Defined | Excel Programming | |||
Runtime error 1004- application defined or object defined erro | Excel Programming | |||
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error | Excel Programming | |||
Macro Run-time Error 1004 Application Defined or Object Defined Error | Excel Programming |