Is it possible to automate the creation of Microsoft Office macros? i.e. create a different macro, based on different input data?

Viewed 35

I need to create a document where employees will have to answer a few questions. These documents will be emailed. Part of the data we already have stored and we expect not to change - name, email, phone etc

The employee will be required to enter these details again and - if they don't match our records, will be prompted with Outlook opening an email to notify HR to update their details

I have never actually used macros before and couldn't find if it's possible to actually generate unique macros from googling - basically, the kind of psuedocode I'd want is:

if NameTextField.Text == "Joe Bloggs"{
    //ok - allow user to submit document
}else{
    Choice = MsgBox("This doesn't match our records - please check your input or contact HR to update your details", ChangeRecordsBtn, CancelBtn)
    if Choice == ChangeRecordsBtn{
        //open Outlook with pre-populated subject & message body
    } 
}

So basically I want to hard-code the unique data - name, email, telephone etc - into the macro itself? Is this possible?

I am open to any solutions - either if it's possible to do it using an official product. Otherwise, if anyone knows any open source project in any language that would allow me to do this, I'd appreciate that too

Thanks

1 Answers

I'm not aware of a way to write a macro using Code. The way I would get round this is to create workbook in Excel which would be my template. The Template would have a hidden data sheet which you can put the known data into and a form which the end user will complete. You can create an embedded macro within the form that does the checks you describe. Then you can create a macro in a separate workbook that loops through each end user, opens the template, unhides the hidden sheet and populates it with the data and then rehides the sheet and emails the new workbook to the user.

Related