REM ***** BASIC ***** Sub ToASCII oDoc = thisComponent FileSaver(false) 'Protect user's file oVC = oDoc.CurrentController.getViewCursor() oVC.goToStart(false) oText = oDoc.Text ParaBreak = com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK Do 'Insert breaks after all lines. oVC.goToEndOfLine(false) oTC = oText.createTextCursorByRange(oVC) If NOT oTC.isEndOfParaGraph then 'Test for end of normal or blank para. oTC.goRight(1,true) 'Check the next character. If ASC(oTC.String) = 10 then oTC.String = "" 'If a line break then delete it. oText.insertControlCharacter(oVC,ParaBreak,false) oVC.goLeft(1,false) 'Move in front of the inserted para. break. EndIf oVC.gotoStartOfLine(false) 'Move back to where we started from. Loop While oVC.goDown(1,false) 'Goes to next line or returns false if none. FileSaver(true) End Sub Sub FileSaver(Finish as Boolean) 'Set the application extension for new file: Static WasPath : Static SavePath : AppExt = ".txt" '<======================= GlobalScope.BasicLibraries.LoadLibrary("Tools") If (Finish) then goto Final WasPath = convertFromURL(thiscomponent.URL) : WasCopy = WasPath If (WasPath = "") then WorkURL = GetPathSettings("Work") : WorkPath = convertFromURL(WorkURL) + "\" Waspath = InputBox("Enter a file name or full path","UNSAVED FILE",WorkPath) If (Instr(WasPath,".") = 0) then WasPath = WasPath + AppExt If (Instr(convertToURL(WasPath),"/") = 0) then WasPath = WorkPath + WasPath EndIf While Mid(convertToURL(WasPath),Len(convertToURL(WasPath))-NAMElon,1) <> "/" NAMElon = NAMElon + 1 Wend Do If Mid(WasPath,Len(WasPath)-NAMEcnt,1) = "." then NAMEext = Right(WasPath,NAMEcnt+1) : NAMEloe = Len(NAMEext) : Exit Do EndIf NAMEcnt = NAMEcnt + 1 Loop While NAMEcnt < NAMElon SavePath = WasPath : If (Right(SavePath,NAMEloe) <> AppExt) then SavePath = SavePath + AppExt Do WasPath = Left(WasPath,Len(WasPath)-NAMEloe) + ".B4" + NAMEext Loop While FileExists(WasPath) If (FileExists(SavePath) and SavePath <> WasCopy) then iAns = MsgBox("OK to OVERWRITE: " & Chr(13) & SavePath & " ?",36,"EXISTING FILE") If (iAns <> 6) then End EndIf thisComponent.StoreToURL(convertToURL(WasPath),Array()) Exit Sub Final: sURL = convertToURL(SavePath) thisComponent.storeAsUrl(sURL, Array(MakePropertyValue("FilterName","Text"))) a$ = "Your original file was saved as:" & Chr(13) & WasPath & Chr(13) b$ = "Your new file was saved as:" & chr(13) & SavePath : MsgBox a$ & b$ End Sub 'An unadulterated DannyB function. Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue Dim oPropertyValue As New com.sun.star.beans.PropertyValue If Not IsMissing( cName ) Then oPropertyValue.Name = cName EndIf If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue EndIf MakePropertyValue() = oPropertyValue End Function