Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Logging things..

Mornin' all!

I'm using something like this to log progress and errors
etc to a text file:

LogFile = CleanFolderPath("MY FOLDER PATH HERE") & MyDoc
& " Run Log.txt"
Open LogFile For Output As #1
Print #1, "Report page " & MyRepName & " saved to " &
MySaveLocation

etc etc.

There is the potential for two files to be open at once,
how can I use the first available number instead of the #1?

Cheers,
Foss
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Logging things..

FreeFile is what retrieves the number you're after:

Sub test()
intFreeFile1 As Integer, intFreeFile2 As Integer

LogFile = CleanFolderPath("MY FOLDER PATH HERE") & MyDoc & " Run
Log.txt"
intFreeFile1 = FreeFile
Open LogFile For Output As #intFreeFile1
intFreeFile2 = FreeFile
Open LogFile2 For Output As #intFreeFile2
Print #intFreeFile1, "Report page " & MyRepName & " saved to " &
MySaveLocation
Print #intFreeFile2, "Something else"
End Sub

I assume here that you're closing the file afterward.
In this example it would be:
Close #intFreeFile2
Close #intFreeFile1


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Foss" wrote in message
...
Mornin' all!

I'm using something like this to log progress and errors
etc to a text file:

LogFile = CleanFolderPath("MY FOLDER PATH HERE") & MyDoc
& " Run Log.txt"
Open LogFile For Output As #1
Print #1, "Report page " & MyRepName & " saved to " &
MySaveLocation

etc etc.

There is the potential for two files to be open at once,
how can I use the first available number instead of the #1?

Cheers,
Foss



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Logging things..

Thanks very much! That's just what I'm after!

After a few problems earlier on, I'm now closing my files!!

Cheers,
Foss

-----Original Message-----
FreeFile is what retrieves the number you're after:

Sub test()
intFreeFile1 As Integer, intFreeFile2 As Integer

LogFile = CleanFolderPath("MY FOLDER PATH HERE") &

MyDoc & " Run
Log.txt"
intFreeFile1 = FreeFile
Open LogFile For Output As #intFreeFile1
intFreeFile2 = FreeFile
Open LogFile2 For Output As #intFreeFile2
Print #intFreeFile1, "Report page " & MyRepName & "

saved to " &
MySaveLocation
Print #intFreeFile2, "Something else"
End Sub

I assume here that you're closing the file afterward.
In this example it would be:
Close #intFreeFile2
Close #intFreeFile1


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Foss" wrote in

message
...
Mornin' all!

I'm using something like this to log progress and errors
etc to a text file:

LogFile = CleanFolderPath("MY FOLDER PATH HERE") & MyDoc
& " Run Log.txt"
Open LogFile For Output As #1
Print #1, "Report page " & MyRepName & " saved to " &
MySaveLocation

etc etc.

There is the potential for two files to be open at once,
how can I use the first available number instead of the

#1?

Cheers,
Foss



.

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
Logging Conversations Rugby Stud Excel Discussion (Misc queries) 1 June 19th 09 11:32 PM
Logging changes SPISO Excel Discussion (Misc queries) 0 May 12th 09 05:44 PM
Logging information SPISO Excel Worksheet Functions 0 April 22nd 09 02:16 PM
Logging a website information. Nneuromancer Excel Worksheet Functions 0 August 18th 06 01:19 PM
Logging into a website Jackblack1 Excel Discussion (Misc queries) 0 May 31st 06 05:27 PM


All times are GMT +1. The time now is 07:08 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"