Headlines Today's Cyber Security Cryptography Algorithm Games Dev

Difference between vbCr, vbCrLf, and vbLf


Jonathan Caceres, Oct 17, 12:24

vbCr : - return to line beginning
Represents a carriage-return character for print and display functions.

vbCrLf : - similar to pressing Enter
Represents a carriage-return character combined with a linefeed character for print and display functions.

vbLf : - go to next line
Represents a linefeed character for print and display functions.



VBA Programming Language Reference


Jonathan Caceres, Oct 17, 08:05

VBA PROGRAMMING REFERENCE
FOR NEXT LOOP

Dim Found, MyObject, MyCollection 
Found = False    ' Initialize variable. 
For Each MyObject In MyCollection    ' Iterate through each element.  
    If MyObject.Text = "Hello" Then    ' If Text equals "Hello". 
        Found = True    ' Set Found to True. 
        Exit For    ' Exit loop. 
    End If 
Next


How to adjust Word document white spaces or empty spaces


Jonathan Caceres, Sep 20, 03:29

Sometimes adjusting empty spaces or white spaces is not easy, for example like this:

 Emergency contacts
      Hospital:  07-9854-86547   
      Ambulance:    123
      Fire Brigade: 021
      Police: 425

to create a align look you could use [ Shift  SPACE bar ] it reduce the empty spaces between word.  

 Emergency contacts
      Hospital    : 07-9854-86547   
      Ambulance   : 123
      Fire Brigade: 021
      Police      : 425

You can also try CRTL D this option help to modify other futures of your text such as

    Strikethrough                   This virus can be is found in most environments 
    Double strikethrough
    Supercript
    Subscript
    Small caps
    All caps
    Hidden




How to modified the Personal Information MS Office Word


Jonathan Caceres, Mar 10, 11:08
Case
You have a Word file called Original1.docx where the author on the file is
the computer users name but not your name. How we can change name? 

Image 1 shows the name Trans we need to change with Smith. Here is the steps 
to follow:

1.  Copy the File Original1.docx and rename it with Original2.docx on the same directory or path
2.  Open the file Original2.docx go to Review and then Reject All Changes
3.  Using Compare Files go to Review select Compare then first the Original1.docx
    after the Original2.docx
4.  Label changes with under Revised document or Original2  your name Smith in this case   
5.  In the Compare Popup window it shows the changes select the Original Document
    and Word Level also make sure the following settings: 

    Comparison settings is check All 
	Moves
	Comments
	Formatting
     Case changes
	White space
	Tables
	Headers and footers
	Footnote and endnotes
	Textboxes
	Fields

6.  Show Changes select Word level and original document
7.  Then Accept all changes click YES

 Now your review panel is Smith 


Odd ASCII code useful for Professional Documentation


Jonathan Caceres, Mar 09, 06:00

Symbol name            Example            Code       ASCII

Temperature degrees    °C or °F        Alt + 248       °
Diameter                   ø50         Alt + 0248      ø
Multiplication           14 × 2        Alt + 0215      ×
Do not brake  formula     32 °C        Alt + 0160     never brake this formula into a new line


How to add width between cells in CSS, Word and Excel


Jonathan Caceres, Oct 17, 08:00

Word 

1. Table properties 
2. Table options
3. Check the "Allow spacing between cells"    0.05 cm 

CSS

td { 
    padding: 10px;
}

table { 
    border-spacing: 10px;
    border-collapse: separate;
}


Excel

1. Menus
2. Format Cells
3. Alignment  Indent  0




Productive at work Microsoft Office Word


Jonathan Caceres, Oct 17, 08:07
How to open a Word document and change a string programatically

Microsoft Email Exchange $8

Imports Word = Microsoft.Office.Interop.Word  
Public Class Form1  
 
    ' Find / Replace in Word Document  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
                Handles Button1.Click  
        Dim objWordApp As New Word.Application  
        objWordApp.Visible = True 
 
        'Open an existing document.  
        Dim objDoc As Word.Document = objWordApp.Documents.Open("C:\yourdirectory\your_file.doc")  
        objDoc = objWordApp.ActiveDocument  
 
        'Find and replace some text  
        'Replace 'VB' with 'Visual Basic'  
        objDoc.Content.Find.Execute(FindText:="VB", 
            ReplaceWith:="Visual Basic Express", Replace:=Word.WdReplace.wdReplaceAll)  
        While objDoc.Content.Find.Execute(FindText:="  ", Wrap:=Word.WdFindWrap.wdFindContinue)  
            objDoc.Content.Find.Execute(FindText:="  ", ReplaceWith:=" ", 
                 Replace:=Word.WdReplace.wdReplaceAll, Wrap:=Word.WdFindWrap.wdFindContinue)  
        End While 
 
        'Save and close the document  
        objDoc.Save()  
        objDoc.Close()  
        objDoc = Nothing 
        objWordApp.Quit()  
        objWordApp = Nothing 
 
    End Sub 
End Class 



Microsoft Word Useful Macros VB.net


Jonathan Caceres, Oct 17, 08:09
Enumerate paragraphs in a range

**** Enumarate Paragraphs **** Private Sub EnumerateParagraphs() Dim curDoc As Word.Document = WordApp.ActiveDocument Dim newDoc As Word.Document Dim rng As Word.Range Dim str As String = "" Dim i As Integer rng = curDoc.Content i = rng.Paragraphs.Count() Do Until i = 0 str = str & rng.Paragraphs.Item(i).Range.Text & vbCrLf i = i - 1 Loop newDoc = WordApp.Documents.Add newDoc.Range().Text = str Marshal.ReleaseComObject(rng) Marshal.ReleaseComObject(curDoc) Marshal.ReleaseComObject(newDoc) Select current page range Private Sub SelectedPageRange() Dim curDoc As Word.Document curDoc = WordApp.ActiveDocument curDoc.Bookmarks("\page").Range.Select() Marshal.ReleaseComObject(curDoc) End Sub Microsoft Email Exchange $11
**** Enumerate Sentences ****
Enumerate sentences in a range Private Sub EnumerateSentences() Dim curDoc As Word.Document = WordApp.ActiveDocument Dim newDoc As Word.Document Dim rng As Word.Range Dim str As String = "" Dim i As Integer rng = curDoc.Content i = rng.Sentences.Count() Do Until i = 0 str = str & rng.Sentences.Item(i).Text i = i - 1 Loop newDoc = WordApp.Documents.Add newDoc.Range().Text = str.ToUpper Marshal.ReleaseComObject(rng) Marshal.ReleaseComObject(curDoc) Marshal.ReleaseComObject(newDoc) End Sub
**** Enumerate Sections ****
Enumerate sections Private Sub EnumerateSections() Dim curDoc As Word.Document Dim newDoc As Word.Document Dim str As String = "" Dim i As Integer curDoc = WordApp.ActiveDocument For i = 1 To curDoc.Sections.Count str = str & "SECTION " & i & vbCr str = str & vbTab & "start = " & curDoc.Sections(i).Range.Start str = str & vbTab & "end = " & curDoc.Sections(i).Range.End & vbCrLf Next newDoc = WordApp.Documents.Add newDoc.Range().Text = str Marshal.ReleaseComObject(curDoc) Marshal.ReleaseComObject(newDoc) End Sub
**** Enumerate Section ****
Private Sub CreateSection() Dim curDoc As Word.Document curDoc = WordApp.ActiveDocument curDoc.Sections.Add(WordApp.Selection.Range) Marshal.ReleaseComObject(curDoc) End Sub
**** Enumerate Pages ****
Enumerate pages Private Sub EnumeratePages() Dim curDoc As Word.Document Dim newDoc As Word.Document Dim pgs As Word.Pages Dim str As String = "" Dim i As Integer curDoc = WordApp.ActiveDocument pgs = curDoc.ActiveWindow.Panes(1).Pages For i = 1 To pgs.Count str = "PAGE " & i & vbCr str = str & vbTab & "height = " & pgs.Item(i).Height str = str & vbTab & "width = " & pgs.Item(i).Width & vbCrLf Next newDoc = WordApp.Documents.Add newDoc.Range().Text = str Marshal.ReleaseComObject(pgs) Marshal.ReleaseComObject(curDoc) Marshal.ReleaseComObject(newDoc) End Sub
**** Insert a page break ****
Insert a page break Private Sub InsertPageBreak() Dim sel As Word.Selection sel = WordApp.Selection sel.InsertBreak(Type:=Word.WdBreakType.wdPageBreak) Marshal.ReleaseComObject(sel) End Sub Insert a table Private Sub InsertTable(rowCount As Integer, columnCount As Integer) Dim curDoc As Word.Document = WordApp.ActiveDocument Dim table As Word.Table table = curDoc.Tables.Add(WordApp.Selection.Range, rowCount, columnCount) table.Cell(1, 1).Range.Text = "Hello Table" Marshal.ReleaseComObject(table) Marshal.ReleaseComObject(curDoc) End Sub
**** Enumerate Comments ****
Enumerate comments Private Sub EnumerateComments() Dim curDoc As Word.Document = WordApp.ActiveDocument For i = 1 To curDoc.Comments.Count curDoc.Comments.Item(i).Range.Text = _ curDoc.Comments.Item(i).Range.Text & vbCrLf & _ "Corrected. It's all good now!" Next Marshal.ReleaseComObject(curDoc) End Sub Create a comment Private Sub CreateComment(commentText As String) WordApp.Selection.Comments.Add(WordApp.Selection.Range, commentText) End Sub
**** Delete Comments ****
Delete all comments Private Sub DeleteComments() Dim curDoc As Word.Document = WordApp.ActiveDocument curDoc.DeleteAllComments() Marshal.ReleaseComObject(curDoc) End Sub Insert text Private Sub InsertText(textToInsert As String) WordApp.Selection.InsertAfter(textToInsert) 'WordApp.Selection.InsertBefore(textToInsert) 'WordApp.ActiveDocument.Range.InsertAfter(textToInsert) End Sub
**** Find Text ****
Find text Private Sub FindText() Dim rng As Word.Range rng = WordApp.ActiveDocument.Content With rng.Find .ClearFormatting() .Execute(FindText:="Hello Table", _ ReplaceWith:="Found Table", _ Replace:=Word.WdReplace.wdReplaceAll) End With Marshal.ReleaseComObject(rng) End Sub
**** Copy and paste text ****
Private Sub CopyAndPasteText() Dim curDoc As Word.Document = WordApp.ActiveDocument Dim rng As Word.Range 'Dim sel As Word.Selection rng = curDoc.Range(curDoc.Paragraphs(1).Range.Start, _ curDoc.Paragraphs(3).Range.End) rng.Copy() 'sel = curDoc.Range(curDoc.Paragraphs(1).Range, _ ' curDoc.Paragraphs(3).Range.End) 'sel.Copy() WordApp.Selection.GoTo(What:=Word.WdGoToItem.wdGoToBookmark, _ Name:="\EndOfDoc") WordApp.Selection.Paste() Marshal.ReleaseComObject(rng) Marshal.ReleaseComObject(curDoc) End Sub
**** REFERENCE ****
Working with Word document content objects Posted on Wednesday, August 7th, 2013 at 7:32 am by Ty Anderson. Follow Ty Anderson on Google+, Facebook. Viewed on https://www.add-in-express.com/creating-addins- blog/2013/08/07/word-document-content-objects/


Searching a specific text in Microsoft Word


Jonathan Caceres, Oct 05, 03:37
Macro for searching for a specific string in Word or Excel

Read file content in StreamReader
   StreamReadertxt Reader = new StreamReader(fName);
   ReadAll = txtReader.ReadToEnd();  //Reads the whole text file to the end
   txtReader.Close();                //Closes the text file after it is fully read.
   txtReader = null;

part II of this code at 
  //search word in file content
  if (Regex.IsMatch(szReadAll, "SearchME", RegexOptions.IgnoreCase))
    //If the match is found in allRead
    MessageBox.Show("found");
  else
    MessageBox.Show("not found");