I have data in an Excel spreadsheet that I want to include in a report in Word.
In Excel, one line = one data entry.
In Word, each line will result in a layout block.
There are many lines, I want to define the template once and have whatever function imports from Excel duplicate it as often as necessary.
Mailmerge, AFAIK, creates seperate documents. That is not what I need, I need multiple blocks within one document.
Couldn't find a solution so far, everything points me to Mailmerge.
As requested, an example:
In Excel:
TEST - RESULT - REASON - COMMENT
Check A - failed - missing a foo - install a foo next time
Check B - success - ok - worked as designed
Check C - success - mostly ok - worked, but can be improved
In Word:
Test Report
Check Number: Check A
Check Result: failed (missing a foo)
Comment: install a foo next time
You get the idea. The actual template is not so simple, but the main idea is that fields are not identical to lines - there can be multiple fields in the same line, in different places around the template, etc.
I'm afraid you're not finished with Mail Merge yet!
multiple blocks within one document :
It's the same idea as labels... you're just not printing them onto labels, and you're making up a custo size and layout.
Office.com : Create and print labels using mail merge
More information, Google "word labels from excel data"...
Related
I'm working on a project for our fabrication warehouse. Currently, we have a system where the workers will type in what order they are working on their tablets and then the part numbers, dimensions, etc will all autofill based on a query of all currently open manufacturing orders...
Whenever we have a prototype or expedited part it won't show up in the query. I was wondering if anyone knew some VBA code (or simpler solutions) that would allow us to keep the current data validation but also give operators an option to override.
Example series of events:
1- operator receives and types in order number
2- msgbox pops up saying "this doesn't exist --- is this a prototype or expedited part?" (answer Y/N)
3- Override message pops up "are you sure xxxx is the correct part number" (operator selects yes)
4- data gets inputed as usual but requires manual entries for dimensions, parts used, etc.
psuedo code:
steps 1-3 : a series of if statements and message boxes guiding the decisions is not too difficult
step 4: where im getting tripped up... how would i unlock that row so they could have custom input for that order and then lock it again once they are finished.
Just a suggestion.
What if you add a non-protected column to the file (assuming that each row is a new entry and entry details are stored in columns).
So, one column with data validation and a warning with the text you mentioned.
And another column to enter the order number manually.
I am trying to create a code which will be executed with a click of a button in the excel sheet and will ask me for an input of a cell value in excel which will then take all the data from that cell's row and insert it accordingly in the word template where the mail merge tags are.
for example :
I have data like this in my excel sheet :
ID(A1), Name(B1), Last Name(C1), Country(D1), Date(E1)
378232625(A2), John(B2), Smith(C2), United States(D2), 29/02/2020(E2)
322783145(A3), Joshua(B3), Brand(C3), United States(D3), 27/02/2020(E3)
I want to have a button which will ask for an ID input and will then take all the other info of that person and place it in the word template in the correct place.
For example:
When a user runs the code it will pop up an input box and it will ask him to type an ID,
for example: 322783145
it will then check where the ID is placed(which row in A column) in the excel sheet which is A3 for this example and will pull the rest of this person's information into the word template I have created beforehand.(ID, Name, Last Name, Country and Date).
Later on I want to be able to automatically save it to pdf as well with the same button but first I want this to work.
Thanks in advance :D
You don't need VBA for this with the question as originally posted - simply use a SKIPIF field coded as:
{SKIPIF{MERGEFIELD ID}<> {FILLIN "Which ID do you want?" \o}}
or:
{SKIPIF«ID»<> {FILLIN "Which ID do you want?" \o}}
where 'ID' is the name of the data field in Excel you want to the merge to process.
With that, only the record containing that ID will be processed. No VBA required.
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.
I see that you've added two new requirements, viz:
the mailmerge to be run from a button in Excel; and
for it "to be able to automatically save it to pdf as well".
You really shouldn't move the goal posts this way. Nor should you ask ask multiple distinct questions in the same thread. For code to run a merge from Excel (and send the output to PDF), see Run a Mailmerge from Excel, Sending the Output to Individual Files in the Mailmerge Tips & Tricks thread at: https://www.msofficeforums.com/mail-merge/21803-mailmerge-tips-tricks.html. Of course, once you get into using a macro such as this, you will need to add the logic for the ID selection to that code. Ask in a separate thread if you can't figure that out.
I have an excel sheet that contains percentages. When doing the mail merge, it brings in the percentage as a decimal. I am sure this has been asked before which is why I have researched and tried multiple methods without success.
Currently, a field in excel that shows 60%, will display as 0.599999 in the word document:
When I use the following it rounds the field to 1%:
{MERGEFIELD Payout2 \# ##%}
When I follow the steps below:
select your mergefield, which will look something like «Percent»;
press Ctrl-F9 to wrap another field around it, thus { «Percent» };
edit the field so that you get {=«Percent»*100 \# 0.00%};
position the cursor anywhere in this field and press F9 to update it;
run your mailmerge.
It actuallys changes the field to 60.00% in the word document, which is strange. It should just display the mergefield statement. It's almost like it already picks up the first field from the linked excel document even though I have not ran the merge. Also, when I do actually run the merge, on the last row I get a 5852 error and the field that showed 60.00% now shows !Syntax Error, *
I have a code that automatically creates the documents as the excel sheet has multiple rows. If I leave the payout field as is and not try to adjust it to fix the format, I get no errors (Just the decimal that I don't want).
If its not possible to convert this to a percentage that is fine, at least to a whole number. 60% to 60, so I can add the % symbol manually at the end.
Let me know what additional information is necessary.
You're missing something in your method. Select the entire merge field before F9 to add another.
Your merge field should look like:
Note the braces around the original MERGEFIELD Payout (and you don't type those in manually
If you've done that, in order to go back to see the original merge fields after you've done a preview, you need to select toggle field codes twice. After the first, you'll see the result of the last import into the Payout field, and after the second toggle you'll see the original Payout field code.
My team and I have created a consolidator tool that consolidates data from worksheets uploaded using a button. However, there's an added enhancement that our leads would like to have.
I don't know if it's possible in VBA but what they wanted is a button that checks and highlights "garbage data" (for example: if First Name column contains a blank or if it contains ajsajdj or something similar), it will prompt the user and ask them if they want to delete it.
We already have the code for the consolidator tool (and it's working perfectly) however, this feature is headache inducing as I don't know if it's possible. I would really like to ask suggestions regarding this as I'm really new to VBA and programming.
Maybe, I would be enlightened on what next step I should take.
Let's see how a human would validate that
He would look at the name ajsajdj and think "I have never seen this name in my life before so it must be nonsense data". But he might fail because the fact that he never came accross this name doesn't mean it's not an existing name (parents can be inventive sometimes).
So what a human actually does is comparing the ajsajdj with a list of names (he has in mind because of his experience in life).
Now a program can do the same
You can write a code that compares ajsajdj with a list of valid names. But here we are at the same point where the human can fail too. The list will never be complete because tomorrow parents invent a new name (that you don't have in that list).
Conclusion
This task cannot be coded unless you define a rule for either valid or invalid data. Some programs look like they could do magic, but actually it is only working because of the rules you give them.
I do automated auditing of this type prolifically so I would approach it like this;
Your 'audit macro' is basically an iterator with many quality checks - is 'name' = "", etc. You can run this auto macro either.
On a single line of data each step of the consolidation
After the consolidation has completed.
The first is easiest to use, and works like this:
After your consolidation step run 'auditing macro' on line of data just brought in.
If an issue is found, write the line of data to a separate Tab leaving column A blank; not to your consolidation. At the end of your consolidation give user a warning message if there have been any issue lines found at the end of the consolidation
User skim reads data on separate tab, puts 1s for 'keep' in Column A.
User clicks a button to run a macro which adds the rows with a '1' against them back to your full data set (e.g. on the end if order doesn't matter).
Equally you could approach this by running the audit when the consolidation is totally complete; in this case you'd need to delete or otherwise track rows which may be removed if a user chooses not to keep them.
I like this approach because it is non-blocking; user can leave your consolidator to run without supervising and then deal with exceptions at their convenience. Also you can write/edit as many tests as you want without fundamentally changing your consolidator at all; you can then also start for example counting the number of each issue per import and putting this into a report for continuous improvement... there are options to extend.
In terms of pseudocode its an iterator full of if-else blocks, with a single 'there is an issue' flag, which if it's 1 causes the row to be treated as an issue;
For rowCount = startRow to endRow
' startRow and endRow correspond to lines of data you just imported
'Test 1
if (Some condition e.g. cells(rowCount ,2).value = "") then
issueFlag = 1
End if
'Test n...
if (Some condition e.g. cells(startRow,2).value = "") then
issueFlag = 1
End if
next rowCount
if issueFlag = 1 then
'CODE TO PASTE DATA
'Set some flag/variable which then triggers a Error Message at the end of the whole consolidation or audit
End if
You can put a Exit For at the end of the IF block so if the issueFlag is triggered you immediately exit and skip all further tests.
SharePoint 2013 in Office 365
I have added a custom column to a Document Library. The column is called "Author", and it is a lookup of type People and Group, filtered to show People only, and shows the field Name.
I have a workflow that is conditional upon the column being non-empty, but the Workflow builder doesn't have is empty or is not empty for that Current Item.FieldFromSource (Current Item:Author), so I've read the value into a string variable
Now I can check for existence:
However, I found that the behaviour of the Workflow was somewhat inconsistent, and as you probably know if you've read this far, Workflows are notoriously difficult to debug. So, I created a Task that would run after the loop, assigned to the CurrentUser, that would show the value of the two data items (this in the Task Description):
Value of author = [%Variable: Author_Value%]
Other author = [%Current Item:Author%]
When I run the Workflow (having set the Author to Joe Bloggs) and examine the Task, instead of the author's name it has more-or-less gibberish.
Two questions -
1 - how can I output the Name of the Author, since that's what I thought I'd done?
2 - why is there not an is empty / is not empty for lookups? All of them, no matter what they are bound to, only seem to expose equals / not equals.
Thanks, and hope this makes sense!
Edward
Just discovered that outputting the Current Item:Author as string is the issue - I've changed this to Display Names, Semicolon Delimited and it all works fine. I still don't understand why the condition builder on lookup columns doesn't give you more than equals / not equals but hey ho, this is SharePoint.