Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default How would I select output to a file or Debug?

I have a subroutine that outputs info about pivot tables and I would like the
option to either output the results to a file or to the Immediate window
(Debug.Print). This is the gist of what I'm looking for:

Sub (ToFile as Boolean)
If ToFile Then
Open "C:\PPI.log" For Output As #1
Else
Open Debug.Print for output as #1
End If
Print #1, "...output..."
..
..
..

Yes, the ELSE line does create an error which is why I'm asking. Is there a
form of redirection I can use? I'm looking for something easy, not a whole
gob of IF...THEN...ELSE statements :-o

TIA
--
Toby Erkson
Oregon, USA
Excel 2003 in Windows XP


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How would I select output to a file or Debug?

Tony-

Have you tried your code without the "Open" in front of "Debug.Print"? As I
understand it, the keyword "Debug" is all you need send output to the Debug
(Immediate) window.

-Stan Shoemaker
Palo Alto, CA

"Toby Erkson" wrote:

I have a subroutine that outputs info about pivot tables and I would like the
option to either output the results to a file or to the Immediate window
(Debug.Print). This is the gist of what I'm looking for:

Sub (ToFile as Boolean)
If ToFile Then
Open "C:\PPI.log" For Output As #1
Else
Open Debug.Print for output as #1
End If
Print #1, "...output..."
..
..
..

Yes, the ELSE line does create an error which is why I'm asking. Is there a
form of redirection I can use? I'm looking for something easy, not a whole
gob of IF...THEN...ELSE statements :-o

TIA
--
Toby Erkson
Oregon, USA
Excel 2003 in Windows XP



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How would I select output to a file or Debug?

I think I'd byte the bullet and do something like:

Sub (ToFile as Boolean)
If ToFile Then
Open "C:\PPI.log" For Output As #1 'maybe append???
Print #1, "...output1..."
Print #1, "...output2..."
close #1
Else
debug.print "...output1..."
debug.print "...output2..."
End If

Toby Erkson wrote:

I have a subroutine that outputs info about pivot tables and I would like the
option to either output the results to a file or to the Immediate window
(Debug.Print). This is the gist of what I'm looking for:

Sub (ToFile as Boolean)
If ToFile Then
Open "C:\PPI.log" For Output As #1
Else
Open Debug.Print for output as #1
End If
Print #1, "...output..."
.
.
.

Yes, the ELSE line does create an error which is why I'm asking. Is there a
form of redirection I can use? I'm looking for something easy, not a whole
gob of IF...THEN...ELSE statements :-o

TIA
--
Toby Erkson
Oregon, USA
Excel 2003 in Windows XP


--

Dave Peterson
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
output to the same line in a Text file? Bernard Excel Discussion (Misc queries) 2 November 25th 09 08:12 PM
Need Help With Loop That Creates Output File Jenny Marlow Excel Discussion (Misc queries) 0 April 23rd 08 11:23 PM
Excel 2003 won't let me select my own regression output range. Peter Excel Discussion (Misc queries) 0 August 24th 07 10:30 PM
debug message pops up when I select a range of cells and delete Brian Excel Programming 6 October 17th 04 12:55 AM
VBA help to output a file Paula Weill Excel Programming 2 September 20th 04 02:12 PM


All times are GMT +1. The time now is 03:45 AM.

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"