From: mp on 19 Jun 2010 14:13 I'm using this but it prints one blank line...how to just end up with a blank file? Dim oFile As cFile Set oFile = New cFile oFile.Filename = mSelectedFoldersFile oFile.OverWrite "" and in cFile class Public Sub OverWrite(sMsg As String) Dim iFhndl As Long iFhndl = FreeFile On Error GoTo ERRCTL Open msFilename For Output As #iFhndl Print #iFhndl, sMsg 'Write #iFhndl, sMsg '---write adds quotes around text ExitHere: Close #iFhndl On Error GoTo 0 Exit Sub ERRCTL: If Err Then Err.Clear LogError "Unable to write to file " & msFilename & " check write permissions" End If Resume ExitHere End Sub thanks mark'
From: Mike Williams on 19 Jun 2010 16:38 "mp" <nospam(a)Thanks.com> wrote in message news:eX9eXs9DLHA.1868(a)TK2MSFTNGP05.phx.gbl... > . . . but it prints one blank line...how > to just end up with a blank file? Print #iFhndl, sMsg; Mike
From: Rick Rothstein on 19 Jun 2010 19:04 I think if you just open the file for Output and then close it immediately, the file will exist, but be empty. ....... ....... Open msFilename For Output As #iFhndl Close #iFhndl ....... ....... -- Rick (MVP - Excel) "mp" <nospam(a)Thanks.com> wrote in message news:eX9eXs9DLHA.1868(a)TK2MSFTNGP05.phx.gbl... > I'm using this but it prints one blank line...how to just end up with a > blank file? > > Dim oFile As cFile > Set oFile = New cFile > oFile.Filename = mSelectedFoldersFile > oFile.OverWrite "" > > and in cFile class > Public Sub OverWrite(sMsg As String) > Dim iFhndl As Long > iFhndl = FreeFile > On Error GoTo ERRCTL > Open msFilename For Output As #iFhndl > Print #iFhndl, sMsg > 'Write #iFhndl, sMsg '---write adds quotes around text > ExitHere: > Close #iFhndl > On Error GoTo 0 > > Exit Sub > ERRCTL: > If Err Then > Err.Clear > LogError "Unable to write to file " & msFilename & " check write > permissions" > End If > Resume ExitHere > End Sub > > thanks > mark' > >
From: mp on 19 Jun 2010 19:47 Very cool Thank you "Rick Rothstein" <rick.newsNO.SPAM(a)NO.SPAMverizon.net> wrote in message news:uXOdGPAELHA.4816(a)TK2MSFTNGP04.phx.gbl... >I think if you just open the file for Output and then close it immediately, >the file will exist, but be empty. > > ...... > ...... > Open msFilename For Output As #iFhndl > Close #iFhndl > ...... > ...... > > -- > Rick (MVP - Excel) > > > > "mp" <nospam(a)Thanks.com> wrote in message > news:eX9eXs9DLHA.1868(a)TK2MSFTNGP05.phx.gbl... >> I'm using this but it prints one blank line...how to just end up with a >> blank file? >> >> Dim oFile As cFile >> Set oFile = New cFile >> oFile.Filename = mSelectedFoldersFile >> oFile.OverWrite "" >> >> and in cFile class >> Public Sub OverWrite(sMsg As String) >> Dim iFhndl As Long >> iFhndl = FreeFile >> On Error GoTo ERRCTL >> Open msFilename For Output As #iFhndl >> Print #iFhndl, sMsg >> 'Write #iFhndl, sMsg '---write adds quotes around text >> ExitHere: >> Close #iFhndl >> On Error GoTo 0 >> >> Exit Sub >> ERRCTL: >> If Err Then >> Err.Clear >> LogError "Unable to write to file " & msFilename & " check write >> permissions" >> End If >> Resume ExitHere >> End Sub >> >> thanks >> mark' >> >>
From: mp on 19 Jun 2010 19:48
"Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message news:OhHN09%23DLHA.588(a)TK2MSFTNGP06.phx.gbl... > "mp" <nospam(a)Thanks.com> wrote in message > news:eX9eXs9DLHA.1868(a)TK2MSFTNGP05.phx.gbl... > >> . . . but it prints one blank line...how >> to just end up with a blank file? > > Print #iFhndl, sMsg; > > Mike > is that a semicolon at the end? that wouln't print the blank line i'm getting now? |