Tuesday, August 22, 2017

How to create MS Word document automatically with Text file

This VBA code will help you to import data from a text file and insert into the MS word document. This is useful when you have to create a report or formats in the in MS Word format, reading the data from a text file. The VBA code can be extended import extra data from the text file, and also you can add additional format as per your needs.

Please note that VBA macros can cause harm to your computer. First, open them in a disabled mode. To disable macros, to Developer tab, select macro security and then select Macro settings on the left side pane. In the right pane, select the second radio button, 'Disable all macros with notification'. The second option is better because it will notify you if there are any macros associated with your file. So you will not miss any document features which may be available after running a macro. But you can decide whether to allow the macros to run or not.

Please click on the below link to download the MS Word Template file. You can also download the text file used to import the data. I remind you that this is a sample file. You may have to modify the VBA code according to your requirement. You may have to rename the input file.

Please leave comment below if you have any concerns.
MS word template

The VBA Code
Sub Document_Open()
If (ActiveDocument.Name = "Template.docm") Then
With ActiveDocument
   On Error Resume Next
    .Variables.Add Name:="1", Value:="1"
    .Variables.Add Name:="2", Value:="2"
    .Variables.Add Name:="3", Value:="3"
    .Variables.Add Name:="4", Value:="4"
    .Variables.Add Name:="5", Value:="5"
    .Variables.Add Name:="6", Value:="6"
    Dim ReadData As String
    Dim myarray() As String
    Open ActiveDocument.Path & "\text.txt" For Input As #1

    Do Until EOF(1)
       Line Input #1, ReadData
    If Not Left(ReadData, 1) = "*" Then
    myarray = Split(ReadData, ",")
    End If


    Close #1

    i = 1
    For Each f In myarray
       .Variables(i).Value = f
       i = i + 1
    Next f
End With

With ActiveDocument
strFileName = "Agreement Between " & myarray(5) & " and " & myarray(0)
strPath = .Path

.SaveAs2 (strPath & "\" & strFileName)
'.Close SaveChanges:=wdDoNotSaveChanges
Application.Quit SaveChanges:=wdDoNotSaveChanges
End With
End If
End Sub

Sunday, July 16, 2017

Last week, Reliance had extended its Jio preview offer for Samsung Galaxy users. A lot of people are itching to get one with preview offer. This offer gives you unlimited 4g data, unlimited voice, and unlimited SMS for 90 days. I am one of the lucky guys to get a new Jio SIM with my Samsung Galaxy A5 2016. I got it on Saturday evening 7 O’clock and the guy at Reliance digital said it will be activated by Monday afternoon. But I got it activated on Sunday, 2 O’ clock itself. That was very quick.

How to get the preview offer with Samsung galaxy mobiles

First, you need to install the Jio app called MyJio. As soon as you open the app, on the very first screen you will see Get Jio Preview Offer on top of the screen. Click this and proceed with the other steps.

In the first screen after clicking Get Jio Preview Offer, you will see the details of the offer and terms and conditions. Click "Agree and get Jio Offer".

Next, you will have to check the eligibility. This is nothing but a network availability in your area. Select your state and city. Click Next.

In this step, you have to generate the barcode. Show this barcode to the Reliance Digital salesperson. He will take this and issue a new SIM to you. You have to give him a passport size photo and an address proof and you have to sign the CAF - Customer Application Form at some 2-3 places. Also, you need to give your existing mobile number, to which you will get an activation message. That’s all from your end.

Wait for the message from Jio on your registered mobile number. Once you get the message, call customer care from your registered mobile number, not from your Jio number. Your Jio number may not be activated yet. Talk to the customer care executive, he will guide you what you need to do. Once activated, wait for some time. Your Jio SIM will get registered to the Jio 4G network.

Once all the activation process is complete you will get 2GB of 4g data, 100 minutes of voice and 100 SMS. This is part of your New Prepaid FRC. A lot of people think that this is what we get from Jio and we won't get the unlimited offer. This is wrong. To get the unlimited offer you have one more step to do.

Looking to move from development to DevOps? Here is what you should know

DevOps is a buzz word in the last decade, everybody wants to try their luck in DevOps. DevOps is the most generic area of software engineeri...