Thursday, March 10, 2011

PDF: Portable Document Format


What is PDF and how to use it?
PDF =  Portable Document Format
PDF is a standard to share document files. As compared to word , or wordpad
or any other office documents , PDF has many many more benifits. 
Use of PDF or Portable Document Format:


• Share files with others who don't have the same software
• Share files with others who use a different platform like Mac, Windows, Linux, etc.
• Share files that will look the same (layout, fonts) as on multiple systems
• Share files that can be protected from unauthorized viewing, printing, copying, or editing
• Publish electronic documents, ebooks, etc.
• Print files to many different types of printers, and all look essentially the same
• Create files with annotations, hyperlinks, and bookmarks that can be shared via email and on the Web
• Create interactive forms that can be shared via email and the Web
• Create files that are more efficient than PostScript or native file formats typically used in commercial printing

To View Pdf Files you need a PDF Reader , If you don't have a Pdf Reader you can download it from the linkhttp://www.adobe.com/products/reader.html

Friday, March 4, 2011

Replace text into your .txt file with VBA

FielPath : Location of your Text file including file name. e.g.: c:\abc\abc.txt
oldStr : search string into the file 
newStr: replace the value with oldStr.


Sub TestReplaceTextInFile(filePath As String, oldStr As String, newStr As String)
    ReplaceTextInFile filePath, oldStr, newStr
End Sub

Sub ReplaceTextInFile(SourceFile As String, sText As String, rText As String)
    Dim TargetFile As String, tLine As String, tString As String
    Dim p As Integer, i As Long, F1 As Integer, F2 As Integer
        TargetFile = "RESULT.TMP"
        If Dir(SourceFile) = "" Then Exit Sub
        If Dir(TargetFile) <> "" Then
            On Error Resume Next
            Kill TargetFile
            On Error GoTo 0
            If Dir(TargetFile) <> "" Then
                MsgBox TargetFile & _
                    " already open, close and delete / rename the file and try again.", _
                    vbCritical
                Exit Sub
            End If
        End If
        F1 = FreeFile
        Open SourceFile For Input As F1
        F2 = FreeFile
        Open TargetFile For Output As F2
        i = 1 ' line counter
        Application.StatusBar = "Reading data from " & _
            TargetFile & " ..."
        While Not EOF(F1)
            If i Mod 100 = 0 Then Application.StatusBar = _
                "Reading line #" & i & " in " & _
                TargetFile & " ..."
            Line Input #F1, tLine
            If sText <> "" Then
                ReplaceTextInString tLine, sText, rText
            End If
            Print #F2, tLine
            i = i + 1
        Wend
        Application.StatusBar = "Closing files ..."
        Close F1
        Close F2
        Kill SourceFile ' delete original file
        Name TargetFile As SourceFile ' rename temporary file
        Application.StatusBar = False
End Sub


Private Sub ReplaceTextInString(SourceString As String, _
        SearchString As String, ReplaceString As String)
    Dim p As Integer, NewString As String
        Do
            p = InStr(p + 1, UCase(SourceString), UCase(SearchString))
            If p > 0 Then ' replace SearchString with ReplaceString
                NewString = ""
                If p > 1 Then NewString = Mid(SourceString, 1, p - 1)
                NewString = NewString + ReplaceString
                NewString = NewString + Mid(SourceString, _
                    p + Len(SearchString), Len(SourceString))
                p = p + Len(ReplaceString) - 1
                SourceString = NewString
            End If
            If p >= Len(NewString) Then p = 0
        Loop Until p = 0
End Sub

Some funny JScripts


(1) Copy and paste the java script code to the address bar of your browser and Press Enter. Watch your window's "shaking it" !!!

javascript:a=0;x=0;y=0;setInterval("a+=.01;x=Math.cos(a*3)*200;
y=Math.sin(a*2)*2;moveBy(x,y)",2);void(0)



(2) Float the Body of your webpage.

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("body");DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);


(3) Start Editing any web Page... and have some Fun !!!

javascript:document.body.contentEditable='true'; document.designMode='on'; void(0)