Automate Mail Merge to Save Each Record Individually in MS Word | Step-By-Step Word VBA Tutorial

  Рет қаралды 118,220

Jie Jenn

Jie Jenn

Күн бұрын

Пікірлер
@jiejenn
@jiejenn 4 жыл бұрын
Want to add couple things here: 1) When your table header name contains a space, for example Account Name, because a data source field cannot have a space, VBA will automatically replace space with an underscore. So when you type your DataFields' name, instead of DataFields("Account Name").value, you want to use DataFields("Account_Name").value. 2) I will be working on a Mail Merge Utility with a UI with to eliminate the need to write VBA code. Also looking adding few useful features to enhance the functionality. 3) and try not use special characters in your file name. And lastly, thank you for all of your support and views. I appreciate it.
@nageshnagasubramanian1185
@nageshnagasubramanian1185 3 жыл бұрын
Jie Jenn, this was very useful. Can you tell how to few lines of code to combine 2 or more pdf files together in this script of yours?
@RESULTCELLSR
@RESULTCELLSR Жыл бұрын
Thank You for a clean crisp code! It has provided me the solution in the first go!!!
@PURVESHPRAJAPATI-tm7ds
@PURVESHPRAJAPATI-tm7ds 3 жыл бұрын
Thanks. Jin. It is a very useful and timesaving clerical job which is widely used in corporates and other sectors. One my relative is in the HR department and he used to print and save the Increment / Bonus Letters individually by each employee and send by email to them. You can imagine how painful and time-consuming job for more than 500 employees. I shared this example and he is very happy to save his time by such Automation. Thanks Jin Again for your efforts.
@jynxie88
@jynxie88 3 жыл бұрын
You are a lifesaver! There were some moments where I hit a roadblock, but meddled here and there and it saved my team's time, a LOT of it! Thank you so much sir.
@jiejenn
@jiejenn 3 жыл бұрын
Glad my video helped. Cheers.
@Ryangaming862
@Ryangaming862 4 жыл бұрын
I cannot thank enough for this tutorial, very useful and extremely helpful for someone like me. hours of work in minutes. thanks once again for sharing your knowledge :)
@imranism
@imranism 5 жыл бұрын
This is amazing, It is a generic tool which can save each record from Excel in a customized pdf or word template.
@DarrylDevar
@DarrylDevar 4 жыл бұрын
Thank you, saved me a lot of time. Really appreciate this, nobody has a tutorial as detailed as yours. I also get a blank page at the end of every pdf with my first-page Header and Footer page included.
@jiejenn
@jiejenn 4 жыл бұрын
Check your document margin, could be there are some spaces extended outside the page.
@DarrylDevar
@DarrylDevar 4 жыл бұрын
@@jiejenn I still have the 1st page with my letterheads appearing on a blank page at the end, is there anyway of fixing this. Or printing only a certain number of pages so that i exclude the last empty page that appears.
@DarrylDevar
@DarrylDevar 4 жыл бұрын
Thank you, it was a spacing issue
@Xaphoeous
@Xaphoeous 4 жыл бұрын
THANK YOU! This video, and especially the link to the VBA code, saved me hours and hours of work!
@ceciliaknights8306
@ceciliaknights8306 3 жыл бұрын
Dude!!! This worked so well!! You saved me hours of work, thank you so so much!
@viveknakarmi3411
@viveknakarmi3411 3 жыл бұрын
You are a legend!!!Thanks for this.
@mauriciocovarrubias8255
@mauriciocovarrubias8255 4 жыл бұрын
Thanks a lot for sharing this wonderful tool. As a public server I need to send legal sheets with same info to different people and it works great! I dont have great knowledge of VBA but you made it so easy. At first I had troubles but with patiente I made it work. Greetings fro México.
@joanaamorfajardo3056
@joanaamorfajardo3056 2 жыл бұрын
This is very helpful. It helped me accomplish my task! Thank you so much!
@9716367288
@9716367288 3 жыл бұрын
Omg..... Omg... Finaly i got vba code for mail merge for docx ans save file in docx... Thnk lost.... It very help full me.... 🙏🙏🙏
@melissaaguirre3193
@melissaaguirre3193 3 жыл бұрын
THANK YOU SO MUUUUUUUUUUCHHH FOR THIS!!!!
@jiejenn
@jiejenn 3 жыл бұрын
Glad my video helped.
@smithlithium06
@smithlithium06 4 жыл бұрын
You have saved me a lot of time! Thank you!
@josephaggrey9972
@josephaggrey9972 4 жыл бұрын
This video is fantastic. It actually addressed what I was looking for. Great job. well done Jie.
@jiejenn
@jiejenn 4 жыл бұрын
Glad my video helped!
@helifox
@helifox 3 жыл бұрын
Thank you very much, you save a lot of my time !!!
@jiejenn
@jiejenn 3 жыл бұрын
Glad my video helped.
@ramanandkashyap5167
@ramanandkashyap5167 4 жыл бұрын
Woah!! This is awesome Jie. Thank you very much. Working perfectly fine.
@dariotedesco8652
@dariotedesco8652 10 ай бұрын
thanks for your video. Unfortunately I have a problem when I run the code; a table will appear to confirm data source, I click on Show all and retreive my data source file choosing "Excel files ODBC (*xlsx), then I have the SelectTable window, I click on Options, Show, and I tick everything. I select the sheet where the specified column is, the window closes and then nothing happens. Do I maybe do something wrong? Thanks
@ihzaraki
@ihzaraki 3 жыл бұрын
Thank you so much, it's so easy to follow your step
@MalinaC
@MalinaC 3 жыл бұрын
Awesome! Thank you!
@nelsoncardona4910
@nelsoncardona4910 3 жыл бұрын
Thanks man!
@chrislopez1414
@chrislopez1414 4 жыл бұрын
Genius!!! You are amazing !!!!!
@rachitnirmal
@rachitnirmal 4 жыл бұрын
You are savior! Thank you so much! This was smooth like anything!
@curlcurllocal
@curlcurllocal 3 жыл бұрын
This is fantastic thanks for sharing
@mcclusky21
@mcclusky21 5 жыл бұрын
This was a lifesaver thank you so much for this workaround!!! I had to watch a few times, but very easy to follow. Had to remove the SQLStatement though.
@YippeeKanYe
@YippeeKanYe 5 жыл бұрын
Same here, thank you Sharrod
@f.p.186
@f.p.186 5 жыл бұрын
@@YippeeKanYe i have a problem with that line as well, did you delete the sql statement after the comma or the whole line? (. Opendatasource name=....)
@YippeeKanYe
@YippeeKanYe 5 жыл бұрын
@@f.p.186 I deleted the whole line i.e. .Opendata...
@eduardostewart412
@eduardostewart412 4 жыл бұрын
Thank you so much. Initially had blank pages, had to import and run the module from within the project/document section, not the normal section in the VBA editor tree window on the left screen (don't know proper name right now).
@johnvanco2959
@johnvanco2959 4 жыл бұрын
I have the same issue, what do you mean by running the module from within the project/document section ? Thanks for your help !
@eduardostewart412
@eduardostewart412 4 жыл бұрын
@@johnvanco2959 in the vba window tree on the left. It will list a generic version and a line for the document you have open that you want to run it in. Click on the actual doc and then run/press play
@csm191
@csm191 3 жыл бұрын
Thanks for posting your solution!
@TOMRYANLUKE
@TOMRYANLUKE 3 жыл бұрын
THANK YOU FOR THIS!
@breodjebi
@breodjebi 3 жыл бұрын
This is awesome. Thank you very much. Working perfectly fine
@soaresian
@soaresian 4 жыл бұрын
Thanks this is very helpful and simplified compared to all the complex threads out there.
@PedersensTravels
@PedersensTravels 4 жыл бұрын
Greatly appreciate your sharing this. Struggled to find an effective solution elsewhere. Been awhile since I coded last. Your delivery was excellent and easy to replicate. Only real hiccup I had was the SQL code. SOURCE_FILE_PATH was correct (I set a Watch) yet stepping through the line, I'd consistently get the full filename path truncated (e.g. c:\1\2\3\file.xlsx, came back as c:\1\2\file.xlsx). Solution: Replace database$ with the name of the table containing the data in the xlsx. Worked beautifully. Thanks!
@jiejenn
@jiejenn 4 жыл бұрын
Glad my video helped.
@nelubadalan22
@nelubadalan22 4 жыл бұрын
Great job !
@ghsskomal2458
@ghsskomal2458 Жыл бұрын
dear sir thank you for your tutorial
@tameraziz2104
@tameraziz2104 3 жыл бұрын
Perfect, thank you so much..
@brianogutu723
@brianogutu723 5 жыл бұрын
Worked like a charm!Thanks alot
@JOSHI-l1m
@JOSHI-l1m 4 жыл бұрын
mind blowing, superb knowledge you holding and speed of writing macros
@rajivraj6441
@rajivraj6441 Жыл бұрын
Thanks for the information, what if I want to save only 1 or 2 letters from the table and not the rest. How can this be done.
@nguyenthanhmy1702
@nguyenthanhmy1702 5 жыл бұрын
From Vietnam, thanks for sharing! It helps a lot
@devenderrohilla
@devenderrohilla 4 жыл бұрын
Very nice...great way to explain and fully functional...thank you
@ogechinnadozie7284
@ogechinnadozie7284 4 жыл бұрын
Thank you Jie Genn, the video explains all I'm looking for. I'm practically new with VBA Codes and I'm having a hard time understanding how you went about the "destination" which bears the mail merge automation. Could you do a little explanation on that? Thanks.
@jiejenn
@jiejenn 4 жыл бұрын
Not following your question. What do you mean by "destination"? Do you mean save your files in a different folder?
@ogechinnadozie7284
@ogechinnadozie7284 4 жыл бұрын
I meant the first line " folder_saved as string" the folder named "destination" I would like to know it's content and how to go about it? I know the second file is the Excel sheet containing the data. Can I work with an "xslm" file in this case
@japurba
@japurba 5 жыл бұрын
This is great!! Thank you brother!
@simonsylow1365
@simonsylow1365 3 жыл бұрын
Hello mate thank you so much for the toturtial! everything works however the documents crated seems to be all empty, can you help me with this problem?
@jiejenn
@jiejenn 3 жыл бұрын
Replied your email.
@maheshbabu2523
@maheshbabu2523 5 жыл бұрын
Thanks so much Jie for all the effort.
@selfreflections3066
@selfreflections3066 4 жыл бұрын
Thank You. Lots of blessings for you... This is so powerful.
@R0b3
@R0b3 3 жыл бұрын
Works great form me!!! Thanks a lot for your script. ;-)
@flagshipfleet
@flagshipfleet 4 жыл бұрын
So nice. Thank you very much
@stuartsharp8071
@stuartsharp8071 4 жыл бұрын
Good tutorial, although not sure what I have done wrong. Managed to take a 49 page (49 individual letters) mail merged document and end up with 49 versions of the same each with the 49 pages each, instead of 49 documents with a letter each.
@mauriciocovarrubias8255
@mauriciocovarrubias8255 4 жыл бұрын
Happened the same to me. Any solution?
@suescherer5491
@suescherer5491 4 жыл бұрын
Thanks so much for the tutorial. Very clear. Can you provide the macro text pls.?
@cupricrafts
@cupricrafts 4 жыл бұрын
Do I have to change folder_saved and source_file_path everytime I have a new database and a new document?
@jiejenn
@jiejenn 4 жыл бұрын
Just source file path. Folder saved is where you want your output files to be sact.
@cupricrafts
@cupricrafts 4 жыл бұрын
@@jiejenn And could I set up the saved path to be always the folder of the active document?
@jiejenn
@jiejenn 4 жыл бұрын
@@cupricrafts Sure. Follow the steps below. 1. Remove the line "Const FOLDER_SAVED As String" 2. Inside MailMerge_Automation macro, copy paste the following two lines: Dim FOLDER_SAVED As String FOLDER_SAVED = ThisDocument.Path & "\"
@cupricrafts
@cupricrafts 4 жыл бұрын
@@jiejenn thanks you so much! I'm gonna try the code today 😎
@cupricrafts
@cupricrafts 4 жыл бұрын
@@jiejenn the files are saved in microsoft templates folder, unrelated to the active document.
@mistysword
@mistysword 5 жыл бұрын
Thanks so much for all the effort! This saved my day
@andrewmarcou6164
@andrewmarcou6164 3 жыл бұрын
Hi, Awesome. Quick question, if my word document has a table of contents and I wish to update it is there VBA code to do so for each file?
@ScottAlexander68
@ScottAlexander68 4 жыл бұрын
This is great and it works perfectly. I am wanting to expand on it a bit by selecting the records from the Excel file that have not been "processed" yet. I have that figured out, but I am trying to figure out how to update the excel field to show it as processed so the next time I run the macro, it doesn't pick that record. For example, I want to change the Processed field from No to Yes. Hopefully you understand what I am trying to do.
@jiejenn
@jiejenn 4 жыл бұрын
If you want to process rows based on a condition(s), after the loop, you can insert an IF statement to express your criteria. For example, if your field is called "Processed", the code would look something like IF .fieldname("Processed").value = "Yes" THEN [mail merge code block] END
@ScottAlexander68
@ScottAlexander68 4 жыл бұрын
@@jiejenn I figured that part out after some trial and error. But what I want it to do is after it finds the records and creates the new documents, update the row in Excel so it does not have a duplicate made. For example, say I have 10 rows and I have a "Processed" column. 4 of the 10 rows have No in this column and 6 have Yes. The query finds the 4 rows that were not processed, your script creates the PDF, but I want those rows to change the No to Yes so next time I run the script, these rows will not be created again. Hope that makes sense.
@jiejenn
@jiejenn 4 жыл бұрын
@@ScottAlexander68 I think I understood your question fully now. If you want to update cells in Excel, it involves of adding Excel reference in Word VBA, which is a bit more advanced if you do not have experience in writing VBA. I will take this as an idea and to make a part 2 video in the future.
@ScottAlexander68
@ScottAlexander68 4 жыл бұрын
@@jiejenn Don't have much experience at all. That would be great and I am going to do some reading too lol.
@undrawingend
@undrawingend 2 жыл бұрын
Is it possible to have this make individual folders for each database reference and then have the files save in them locations ? Just out of interest as used this for batch documents in work and it’s been great however it requires moving said file into a folder for each individual letter any advice?
@jiejenn
@jiejenn 2 жыл бұрын
Yeah, it is possible.
@YippeeKanYe
@YippeeKanYe 5 жыл бұрын
Hi Jie, Thank you for this video, very helpful. I have a question about formatting. The data that appears in the newly created word document does not have the proper formatting, i.e. Currency/Accounting/Percentage formatting in the excel file shows up as a general number in word. 6% would show up as 6.0 etc. Any ideas on how to fix this?
@lucasm.s.6118
@lucasm.s.6118 4 жыл бұрын
Great tutorial. Thank you!!
@missyg3183
@missyg3183 5 жыл бұрын
hi, thank you for this, i have a question - i keep getting a debugger error on the open source data line. i see your folder is in C drive, i have to use a W drive - is that the issue? also i get a pop up asking me to select a workbook. any suggestions would be really helpful. thank you!
@jiejenn
@jiejenn 5 жыл бұрын
I don't think drive location should matter, but your error to me seems like Word cannot find the file. The pop up is caused by Word doesn't have the source file linked. If you want, you can send me your VBA code to youtube@learndataanalysis.org and I can take a look at it.
@StuartHough
@StuartHough 5 жыл бұрын
same issue here
@StuartHough
@StuartHough 5 жыл бұрын
I fixed this by unselecting the 'preview results' option in word. It then worked fine!
@julianspb6329
@julianspb6329 5 жыл бұрын
Hello, Thank you very much for the video. When i try to run the code, a tab saying "select table" show ups and when i click okay it say that "Run-time error '5922' unable to find data source". Do you know what i am doing wrong? Thanks
@jiejenn
@jiejenn 5 жыл бұрын
Check your code to see if there are any typos.
@parniunplugged7023
@parniunplugged7023 4 жыл бұрын
@@jiejenn I also got same error. Its something to do with SQL Statement.
@MrWarrentierney
@MrWarrentierney 4 жыл бұрын
Amazing! You are my hero!
@rinarahmawati9472
@rinarahmawati9472 3 жыл бұрын
It's magic 😍
@condee289
@condee289 4 жыл бұрын
Many thanks, it works.!!!
@zarinamustapha8604
@zarinamustapha8604 5 жыл бұрын
Hi, Thanks for the tutorial. It doesn't work when I followed it on a Mac, quite possibly something is different between the two platforms. The macro ran, no error, but no files have been created. I'm not an expert in VB, though
@jiejenn
@jiejenn 5 жыл бұрын
Hi Zarina, I think the object references are a little bit different on Mac. Unfortunately I am not a Mac user nor do I own a Mac PC. Your best bet is look for someone who has a Windows PC and try the mail merge and see if it works.
@romellamarie5608
@romellamarie5608 4 жыл бұрын
@@jiejenn i have the same problem with Zarina, and I'm running Windows. help?
@romellamarie5608
@romellamarie5608 4 жыл бұрын
i.m using word 2013 .. is there a different?
@danwilson4860
@danwilson4860 4 жыл бұрын
I have had the same difficulties. I was able to get the script to MOSTLY work though. Line 19: The 1 to TotalRecord doesn't seem to work, but if you replace TotalRecord with the actual total number of records then it works. Line 33: I cannot get it to save PDFs. If I comment out this line, the script will create unique word files for every merge record, but my Mac chokes on wdExportFormatPDF
@Prasadavajjhala
@Prasadavajjhala 4 жыл бұрын
legend :) thank you
@ashishyadavhr
@ashishyadavhr 4 жыл бұрын
Thanks a lot for sharing this knowledge with us it was very useful. Please advise if we can separate individual documents from a mail merged consolidated file as well? can we use with the same method by making the source as that word file?
@jiejenn
@jiejenn 4 жыл бұрын
Well you can, but depends on the document content organization. Are the pages number consistent for each file? or the page number varies.
@robertanderson9915
@robertanderson9915 3 жыл бұрын
After the OpenDataSource instruction, I get a pop-up which allows me to select the whole worksheet, but then .DataSource.RecordCount = -1. Any ideas why it is not finding my records? Mail merge works normally so I'm sure the source data is ok.
@capt336
@capt336 5 жыл бұрын
Thank you for posting this video. The .Destination = WdSendtoNewDocument seems to make a long word file with every generated document from the Mail Merge put together. Any way how to change it so it just makes the one custom document for each line of source data?
@jiejenn
@jiejenn 5 жыл бұрын
Not sure if it follow. Can you be more specific.
@ngrant8822
@ngrant8822 5 жыл бұрын
Great video Jie Jenn, I have been struggling with the SaveAs2 comment. My Datafield has a '" | " character in the value, I want to save the file name as the 10 characters before the " | " character, can you help me?
@jiejenn
@jiejenn 5 жыл бұрын
| is one of the characters cannot be used to create a file or folder name. You will have to use other characters that is valid.
@fongkaichian9073
@fongkaichian9073 Жыл бұрын
Facing a problem that once merge and the doc / PDF was empty but the PFD file name was correct, any idea?
@jiejenn
@jiejenn Жыл бұрын
Makes sure your PDF content is extractable. If it is an image or encrypted, then it may not work.
@susannescherer7182
@susannescherer7182 2 жыл бұрын
Hello. I have used this macro in the past with good success...a timesaver. Acrobat PDF Maker plug in with Mail merge now does create separate pdf files but still can't name them uniquely so this macro still remains very useful. I however now have an issue that the .pdf files being generated are all blank contents..the name of the file matches what I have in my excel mailmerge database so that source file appears to be set up correctly but the mail merge functionality itself doesn't seem to be running properly. any insight? I am using Office 365... is there perhaps a macro update to use on Office 365?
@jiejenn
@jiejenn 2 жыл бұрын
Hard to tell without looking at your files. One common cause is due to margin is not set correctly.
@susannescherer7182
@susannescherer7182 2 жыл бұрын
@@jiejenn thanks for the reply Jie. Can you clarity how to trouble shoot a margin issue? what should I be looking for? I am unable to send you the file as it contains confidential info. I did however need to really reduce both side, top and bottom margins to maximize the space for my document. thanks in advance
@yogeshdesai3049
@yogeshdesai3049 4 жыл бұрын
Thanks its very helpful kindly share the another vdo for all records save in one pdf format
@abdulwahedcatran8349
@abdulwahedcatran8349 5 жыл бұрын
Thank you so much please how to add a picture to the file
@jiejenn
@jiejenn 5 жыл бұрын
I'm not following your question.
@abdulwahedcatran8349
@abdulwahedcatran8349 5 жыл бұрын
@@jiejenn Let's say we have a logo folder for each client and we want to put this image on the customer's message
@niloofarmaleki3573
@niloofarmaleki3573 4 жыл бұрын
Hello, Many thanks for the video. This was great! My question is In case I want this to be done only for a group of the rows, for example lets say on a column I have category 1,2 and 3, and I want to do this for category 3 only, how should I modify the VBA to apply the filter?
@jiejenn
@jiejenn 4 жыл бұрын
You can actually do that directly in a SQL statement. From the OpenDataSource statement, you can include what we called WHERE clause to include criteria. For example, assuming your column name is "Product Category" and you want to filter the dataset by label "category 1", you would write (noticing the extract double quotation): .OpenDataSource Name:=SOURCE_FILE_PATH, sqlstatement:="SELECT * FROM [$] WHERE [Product Category] IN (""Category 1"")"
@niloofarmaleki3573
@niloofarmaleki3573 4 жыл бұрын
@@jiejenn Many Thanks But actually when I add this where clause, nothing happens... I sent you a video on your email, would you please kindly check?
@nullhas
@nullhas 5 жыл бұрын
Hi Jenn, Pls advise, how to select rows to merge. I do not want to delete previous data.
@Permik123
@Permik123 5 жыл бұрын
After you have connected to your database file on the Word Ribon choose edit recipient list. This is the Microsoft article on the subject. support.office.com/en-us/article/mail-merge-using-an-excel-spreadsheet-858c7d7f-5cc0-4ba1-9a7b-0a948fa3d7d3
@programming304
@programming304 2 жыл бұрын
Hi. How do I get the client name to appear at the beginning of the Word document name once it is saved? The code right now always makes the client name appear at the end of the document name. Thanks.
@jiejenn
@jiejenn 2 жыл бұрын
Once solution is to have a separate column containing the file name, and use that column as the file name instead.
@Master-dh3xl
@Master-dh3xl 3 жыл бұрын
Well done! but I have question with the sql statement if want to retrieve data from row 2 to row 10 how can I do with it? .OpenDataSource Name:=SOURCE_FILE_PATH, sqlstatement:="SELECT * FROM [databases$]" Thanks you.
@TatjanaKovalevica
@TatjanaKovalevica 4 жыл бұрын
thank you, very useful!
@keithng6480
@keithng6480 4 жыл бұрын
Hi! Great tutorial and helped me greatly. However, the macro seems to create an extra empty file after its done with everything... any way for me to correct this?
@jiejenn
@jiejenn 4 жыл бұрын
If you want, you can send me your Word file and your Excel data file to KZbin@LearnDataAnalysis.org and I can take a look.
@jeremybautista5100
@jeremybautista5100 4 жыл бұрын
@@jiejenn Hi was this solved? I am having the same issue
@jeremybautista5100
@jeremybautista5100 4 жыл бұрын
Sorry not the same issue its just all the merges are just blank
@renyap3453
@renyap3453 4 жыл бұрын
how do we set the file destination and file source using the open file dialogue box? thanks!
@jiejenn
@jiejenn 4 жыл бұрын
Maybe this link might help docs.microsoft.com/en-us/office/vba/api/excel.application.inputbox
@renyap3453
@renyap3453 4 жыл бұрын
@@jiejenn hi! I want the string to be field using the filedialog box: Const FOLDER_SAVED As String = "" & Const SOURCE_FILE_PATH As String = "" i cant find ways to work using Application.FileDialog(MsFileDialogFilePicker) & (MSFileDialogFolderPicker)
@renyap3453
@renyap3453 4 жыл бұрын
Its ok now. Ive done it. Thanks alot!
@jiejenn
@jiejenn 4 жыл бұрын
Cool. Glad you figured it out.
@renyap3453
@renyap3453 4 жыл бұрын
@@jiejenn can you also give a video on how to do the mailmerge with dynamic tables?
@dharmeshy3622
@dharmeshy3622 4 жыл бұрын
Thank you, its very useful for me
@valentinabs
@valentinabs Жыл бұрын
Hi Jie, how do I send the individual file to fax numbers? I need to create letters that will go to a list of about 1,000 providers, to let them know their new id number. But it has to go to their individual fax number which is in a column in the excel sheet. I saw there is an option: .Destination = wdSendToFax how do I use that? Thank you for your video. It is so illustrative.
@jiejenn
@jiejenn Жыл бұрын
Do you mind send to a fax machine?
@valentinabs
@valentinabs Жыл бұрын
@@jiejenn i have the spread sheet with providers, provider id and their fax number. So each letter has to go to the provider fax machine. Is that possible?
@jiejenn
@jiejenn Жыл бұрын
To be honest, I am not sure. I haven't fax anything since 2010, so don't know what to tell you.
@diratanaya4889
@diratanaya4889 4 жыл бұрын
Best trick, thanks very much
@LisaLevy-fk3cv
@LisaLevy-fk3cv 8 ай бұрын
Thank you this is great, but I'm having a problem I hope you can help me with, when I try to run it it gives me a runtime error 4198 and points to the .opendatasource line. And suggestions?
@jiejenn
@jiejenn 8 ай бұрын
The error is most likely due to invalid file path is provided.
@91alezander
@91alezander 4 жыл бұрын
It is possible to generate a word template from every excel row individually. In excel I need a button to appear on every new row I populate with data and the button must open the word template that was fill with the data that I populate the row. And also i need the autofill word template to be save in a specified location. Thank you!
@jiejenn
@jiejenn 4 жыл бұрын
Yeah it is doable, but because you want to tie each row per button, you will have to manually re-link the button to each row. It is a pretty time consuming process if you have many records though.
@91alezander
@91alezander 4 жыл бұрын
@@jiejenn Thank you!
@npaverico
@npaverico 4 жыл бұрын
What a great tutorial!! I have one question. I need to put a repeated name in the file name. For example "Approval - Project" . The word Approval has to be in all my file names. How do I include the in the macros?
@jiejenn
@jiejenn 4 жыл бұрын
Within the TargetDoc.SaveAs2 you can concat any addition text you want to include. For example: TargetDoc.SaveAs2 FOLDER_SAVED & .DataSource.DataFields("Client_Name").value & " Approval - Project" & ".docx"
@hestertencate2980
@hestertencate2980 2 жыл бұрын
@@jiejenn can you also do any additional text infront of the name? what would be the code? I've been trying but no idea...
@m.khoerudin3816
@m.khoerudin3816 4 жыл бұрын
thanks, very usefull, but how if want to save with two DataFields, example, name and date
@kethanchordia
@kethanchordia 5 жыл бұрын
Amazing will save me a lot of time. Thank you. Subscribed for life :-)
@tomdenapoli5313
@tomdenapoli5313 3 жыл бұрын
Will this work on a Mac (Office 16). So far, no love.
@林春梅-e9c
@林春梅-e9c 4 жыл бұрын
I have a question, If I just need the pdf File, Can I write a code to delete the files? or can I make a pdf file without creating a word document? Thank you.
@jiejenn
@jiejenn 4 жыл бұрын
You can directly create the PDF without creating the word doc.
@UpYours101
@UpYours101 5 жыл бұрын
Any tips on how to implement this with a variable list. Eg product1, product2 (if exists), ... ?
@jiejenn
@jiejenn 5 жыл бұрын
Never thought of that before. This is interesting, let me experiment a little bit and will get back to you.
@jiejenn
@jiejenn 5 жыл бұрын
Hey there, I think I figured it out but cause give me a specific example.
@UpYours101
@UpYours101 5 жыл бұрын
@@jiejenn So for example: account 1 - has stock AAA valued @100; account 2 has AAA @150, BBB @ 300, CCC @ 250; account 3; has AAA, BBB, CCC, DDD, EEE, FFF; account 4 has AAA, BBB, DDD, ... ZZZ
@thatdudewithachannel
@thatdudewithachannel 4 жыл бұрын
What if you have multiple letters for the same person? Could a file contain multiple letters for the same person?
@lashadolenjashvili9775
@lashadolenjashvili9775 4 жыл бұрын
Hey Jie Jenn, thanks for this tutorial. I am trying to do the same with Publisher, but I can't figure out what to do. Could you please somehow look at my code and give me an advice?
@jiejenn
@jiejenn 4 жыл бұрын
Do you mean Windows publisher?
@lashadolenjashvili9775
@lashadolenjashvili9775 4 жыл бұрын
@@jiejenn I am very glad you answered. Yes, Microsoft Publisher. I have Mail Merge, it is connected to excel sheet. And I want to convert each record to separate PDF. I wrote a simple script, it generates PDFs with correct names, but for some reason each PDF contains only the second record from excel.
@kazisazzad9257
@kazisazzad9257 5 жыл бұрын
Hi, Many thanks for sharing this tutorial. It's amazing and so helpful. It's saving both in word and pdf format; is there any way to avoid saving in word format- please advise.
@jiejenn
@jiejenn 5 жыл бұрын
To avoid saving the word file, I think you can just comment out the line that saves the word file.
@kamiwasielewski1119
@kamiwasielewski1119 2 жыл бұрын
Hi, I am able to produce word and PDF but both file are empty ) no words insite. Can someone help.
@Garlic-d4t
@Garlic-d4t 5 жыл бұрын
Thank you so much!!
@michaelmassette5691
@michaelmassette5691 4 жыл бұрын
I was able to run this but the word docs and PDF files that were created are blank. any ideas?
@jiejenn
@jiejenn 4 жыл бұрын
This seems to be a common problem. Can you send me your data file and your Word doc that contains the VBA code to KZbin@LearnDataAnalysis.org.
@michaelmassette5691
@michaelmassette5691 4 жыл бұрын
Jie Jenn thanks for your reply. I figured out what happened; I forgot to change the name of the worksheet. Your tutorial is extremely helpful. I’m not kidding...what used to take me 4 hours to do now takes me less than 5 minutes. I’m a total noob but getting the hang of it thanks to you. I appreciate your time putting together these tutorials. Very easy to follow and understand.
@michaelmassette5691
@michaelmassette5691 4 жыл бұрын
Is it possible to add another field to the file name? Let’s say I want the company name to pull from one field but I would also like to include the cost center from another field. The file name should look like this: COMPANY_CC9210. Thanks!!
@tysutton9160
@tysutton9160 4 жыл бұрын
Hi Jie, The documents are created with the files saved with the correct names however the document itself is blank. Thoughts?
@eduardostewart412
@eduardostewart412 4 жыл бұрын
same
@tysutton1417
@tysutton1417 4 жыл бұрын
I tried two things and got it to work, first I saved my “template” as a .docm instead of .docx and I moved my source excel and the .docm into the same folder. Changed paths in the Macro of course to go to the new location and it worked. Thanks again Jie Jenn, big fan of your channel!
@eduardostewart412
@eduardostewart412 4 жыл бұрын
@@tysutton1417 i got it to work tonight. The module had to be imported/ran from the within the document/project not the normal section in the VBA editor tree window on the left (don't know the proper name right now).
@thomaskenny6393
@thomaskenny6393 5 жыл бұрын
Thank you! For some reason the names of my files prepend the folder name. So if the destination folder is "Destination", my file names are coming out like this: DestinationMicrosoft DestinationApple DestinationHP DestinationLinux etc. Any idea why that might be happening? Thank you again for sharing.
@jiejenn
@jiejenn 5 жыл бұрын
Without looking at your code I can only guess your file path is missing a slash.
@thomaskenny6393
@thomaskenny6393 5 жыл бұрын
@@jiejenn Ah..Of course. Here is the code. Missing a slash? For recordNumber = 1 To totalRecord With .DataSource .ActiveRecord = recordNumber .FirstRecord = recordNumber .LastRecord = recordNumber End With .Destination = wdSendToNewDocument .Execute False Set TargetDoc = ActiveDocument TargetDoc.SaveAs2 FOLDER_SAVED & .DataSource.DataFields("Vendor_Service_ID") & ".docx", wdFormatDocumentDefault TargetDoc.ExportAsFixedFormat FOLDER_SAVED & .DataSource.DataFields("Vendor_Service_ID").Value & ".pdf", exportformat:=wdExportFormatPDF TargetDoc.Close False Set TargetDoc = Nothing Next recordNumber End With
@thomaskenny6393
@thomaskenny6393 5 жыл бұрын
@@jiejenn Ohhh are you saying my FOLDER_SAVED As String was missing a slash?
@jiejenn
@jiejenn 5 жыл бұрын
@@thomaskenny6393 check your FOLDER SAVED variable value, I think it is indeed missing a slash.
@samanthawakefield8831
@samanthawakefield8831 2 жыл бұрын
Hi. I’ve tried this and when I press F5 it runs like it’s working but it’s not opening a new document? Can you help? Thank you. The code I used is exactly the same as yours.
@jiejenn
@jiejenn 2 жыл бұрын
Hi Samantha, I charge a fee of $10 to troubleshoot. If you are interested please let me know.
@emiliazuloaga3602
@emiliazuloaga3602 4 жыл бұрын
Hello, When I run the VBA and it gets to the .OpenDataSource line of code, another window opens up, the says “select table”, I then click my workbook, click options, then click “system tables” so that the table I am referencing shows up in the window. I then click that table, click ok then nothing happens. No error messages, nothing. Can you help? Thanks
@jiejenn
@jiejenn 4 жыл бұрын
Not sure if I can help you given such little information you provided. If you want, you can send me your data file + Word document (must contain the VBA code) to KZbin@LearnDataAnalysis.org and I can take a look when I have time.
@abdulbaig2099
@abdulbaig2099 4 жыл бұрын
It was great help... i have one more ask i have in the corresponding column password to be input for that file. Note password is different for each file. May be you can think like a SSN Number or Driving licence number for each person as password for them. CAn you help please.
@jiejenn
@jiejenn 4 жыл бұрын
If you want to include password to Word Document, the SaveAs2 method has a parameter called password, and you can supply your password to that parameter. TargetDoc.SaveAs2 FOLDER_SAVED & .DataSource.DataFields("Client_Name").Value & ".docx", FileFormat:= wdFormatDocumentDefault, Password:=""
@abdulbaig2099
@abdulbaig2099 4 жыл бұрын
Thank you Sir! Appreciate your quick reply. however its like this for File 1 the password is 1234 File 2 password is 4567 and so on and its different for each file like mail merge we have different name and id etc..so can we something to input password while saving only with the mail merge from the Excel sheet it can pickup the password
@michaelfaw
@michaelfaw 5 жыл бұрын
I do follow the step that you give. But why the result is blank document and pdf? any idea about this issue?
@jiejenn
@jiejenn 5 жыл бұрын
Without looking at your code, your file, and the error you get, it is nearly impossible to help. I would suggest you post your question on Microsoft Word Forum.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
(1/2) Automating Word Documents from Excel - No VBA
4:37
Andrew Ligon Fant
Рет қаралды 388 М.
Mail Merge from Excel to Microsoft Word
15:03
Technology for Teachers and Students
Рет қаралды 2,8 МЛН
Unlock Excel Secrets: Magic Search Bar You NEVER Knew About!
17:59
PK: An Excel Expert
Рет қаралды 546 М.
Automate Mail Merge with Excel Database using VBA (Macro)
15:15
How to Mail Merge using Power Automate
20:22
Kevin Stratvert
Рет қаралды 292 М.
How to Split Mail Merge into Separate Documents in Microsoft Word
2:35
Chester Tugwell
Рет қаралды 175 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН