Dear VBA Code Expert,
I hope all of you are well.
As I am working in HRM department, I have to prepare a lot of appointment letter. I have a fixed format for appointment letter where I edit manually the candidate name, parents name and other extra info. But now I want to prepare it automatically using vba code from excel.
I have a code by which I can open the word file.
Option Explicit
Sub OPENWORD()
Dim WD As Word.Application
Set WD = New Word.Application
WD.Visible = True
WD.Activate
WD.Documents.Open ("C:\Users\Tarek\Desktop\Appointment Letter.docx")
End Sub
Now, in my appointment letter format, I have to edit a lot of things. For example, in my subject line there is written:
Subject: Appointment Letter for the position of “Manager” under the department of "HRM" in "Recruitment" Section.
I have to edit “Manager”, "HRM", "Recruitment" words every time for new appointment letter. Now i want to do it using macro. Like in excel, in sheet 1, Range B1 represents position name (example: manager), Range B2 represents department name (example: HRM), Range B3 represents section name (example: Recruitment). Now I want to copy B1 and paste in my word document where position is mentioned (replace of manager word), B2 where department is mentioned, B3 where section is mentioned etc.
So, I need help for getting vba code. Can anyone help me?
Thanks in advance.
I hope all of you are well.
As I am working in HRM department, I have to prepare a lot of appointment letter. I have a fixed format for appointment letter where I edit manually the candidate name, parents name and other extra info. But now I want to prepare it automatically using vba code from excel.
I have a code by which I can open the word file.
Option Explicit
Sub OPENWORD()
Dim WD As Word.Application
Set WD = New Word.Application
WD.Visible = True
WD.Activate
WD.Documents.Open ("C:\Users\Tarek\Desktop\Appointment Letter.docx")
End Sub
Now, in my appointment letter format, I have to edit a lot of things. For example, in my subject line there is written:
Subject: Appointment Letter for the position of “Manager” under the department of "HRM" in "Recruitment" Section.
I have to edit “Manager”, "HRM", "Recruitment" words every time for new appointment letter. Now i want to do it using macro. Like in excel, in sheet 1, Range B1 represents position name (example: manager), Range B2 represents department name (example: HRM), Range B3 represents section name (example: Recruitment). Now I want to copy B1 and paste in my word document where position is mentioned (replace of manager word), B2 where department is mentioned, B3 where section is mentioned etc.
So, I need help for getting vba code. Can anyone help me?
Thanks in advance.