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.
@nageshnagasubramanian11853 жыл бұрын
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 Жыл бұрын
Thank You for a clean crisp code! It has provided me the solution in the first go!!!
@PURVESHPRAJAPATI-tm7ds3 жыл бұрын
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.
@jynxie883 жыл бұрын
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.
@jiejenn3 жыл бұрын
Glad my video helped. Cheers.
@Ryangaming8624 жыл бұрын
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 :)
@imranism5 жыл бұрын
This is amazing, It is a generic tool which can save each record from Excel in a customized pdf or word template.
@DarrylDevar4 жыл бұрын
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.
@jiejenn4 жыл бұрын
Check your document margin, could be there are some spaces extended outside the page.
@DarrylDevar4 жыл бұрын
@@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.
@DarrylDevar4 жыл бұрын
Thank you, it was a spacing issue
@Xaphoeous4 жыл бұрын
THANK YOU! This video, and especially the link to the VBA code, saved me hours and hours of work!
@ceciliaknights83063 жыл бұрын
Dude!!! This worked so well!! You saved me hours of work, thank you so so much!
@viveknakarmi34113 жыл бұрын
You are a legend!!!Thanks for this.
@mauriciocovarrubias82554 жыл бұрын
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.
@joanaamorfajardo30562 жыл бұрын
This is very helpful. It helped me accomplish my task! Thank you so much!
@97163672883 жыл бұрын
Omg..... Omg... Finaly i got vba code for mail merge for docx ans save file in docx... Thnk lost.... It very help full me.... 🙏🙏🙏
@melissaaguirre31933 жыл бұрын
THANK YOU SO MUUUUUUUUUUCHHH FOR THIS!!!!
@jiejenn3 жыл бұрын
Glad my video helped.
@smithlithium064 жыл бұрын
You have saved me a lot of time! Thank you!
@josephaggrey99724 жыл бұрын
This video is fantastic. It actually addressed what I was looking for. Great job. well done Jie.
@jiejenn4 жыл бұрын
Glad my video helped!
@helifox3 жыл бұрын
Thank you very much, you save a lot of my time !!!
@jiejenn3 жыл бұрын
Glad my video helped.
@ramanandkashyap51674 жыл бұрын
Woah!! This is awesome Jie. Thank you very much. Working perfectly fine.
@dariotedesco865210 ай бұрын
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
@ihzaraki3 жыл бұрын
Thank you so much, it's so easy to follow your step
@MalinaC3 жыл бұрын
Awesome! Thank you!
@nelsoncardona49103 жыл бұрын
Thanks man!
@chrislopez14144 жыл бұрын
Genius!!! You are amazing !!!!!
@rachitnirmal4 жыл бұрын
You are savior! Thank you so much! This was smooth like anything!
@curlcurllocal3 жыл бұрын
This is fantastic thanks for sharing
@mcclusky215 жыл бұрын
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.
@YippeeKanYe5 жыл бұрын
Same here, thank you Sharrod
@f.p.1865 жыл бұрын
@@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=....)
@YippeeKanYe5 жыл бұрын
@@f.p.186 I deleted the whole line i.e. .Opendata...
@eduardostewart4124 жыл бұрын
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).
@johnvanco29594 жыл бұрын
I have the same issue, what do you mean by running the module from within the project/document section ? Thanks for your help !
@eduardostewart4124 жыл бұрын
@@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
@csm1913 жыл бұрын
Thanks for posting your solution!
@TOMRYANLUKE3 жыл бұрын
THANK YOU FOR THIS!
@breodjebi3 жыл бұрын
This is awesome. Thank you very much. Working perfectly fine
@soaresian4 жыл бұрын
Thanks this is very helpful and simplified compared to all the complex threads out there.
@PedersensTravels4 жыл бұрын
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!
@jiejenn4 жыл бұрын
Glad my video helped.
@nelubadalan224 жыл бұрын
Great job !
@ghsskomal2458 Жыл бұрын
dear sir thank you for your tutorial
@tameraziz21043 жыл бұрын
Perfect, thank you so much..
@brianogutu7235 жыл бұрын
Worked like a charm!Thanks alot
@JOSHI-l1m4 жыл бұрын
mind blowing, superb knowledge you holding and speed of writing macros
@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.
@nguyenthanhmy17025 жыл бұрын
From Vietnam, thanks for sharing! It helps a lot
@devenderrohilla4 жыл бұрын
Very nice...great way to explain and fully functional...thank you
@ogechinnadozie72844 жыл бұрын
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.
@jiejenn4 жыл бұрын
Not following your question. What do you mean by "destination"? Do you mean save your files in a different folder?
@ogechinnadozie72844 жыл бұрын
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
@japurba5 жыл бұрын
This is great!! Thank you brother!
@simonsylow13653 жыл бұрын
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?
@jiejenn3 жыл бұрын
Replied your email.
@maheshbabu25235 жыл бұрын
Thanks so much Jie for all the effort.
@selfreflections30664 жыл бұрын
Thank You. Lots of blessings for you... This is so powerful.
@R0b33 жыл бұрын
Works great form me!!! Thanks a lot for your script. ;-)
@flagshipfleet4 жыл бұрын
So nice. Thank you very much
@stuartsharp80714 жыл бұрын
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.
@mauriciocovarrubias82554 жыл бұрын
Happened the same to me. Any solution?
@suescherer54914 жыл бұрын
Thanks so much for the tutorial. Very clear. Can you provide the macro text pls.?
@cupricrafts4 жыл бұрын
Do I have to change folder_saved and source_file_path everytime I have a new database and a new document?
@jiejenn4 жыл бұрын
Just source file path. Folder saved is where you want your output files to be sact.
@cupricrafts4 жыл бұрын
@@jiejenn And could I set up the saved path to be always the folder of the active document?
@jiejenn4 жыл бұрын
@@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 & "\"
@cupricrafts4 жыл бұрын
@@jiejenn thanks you so much! I'm gonna try the code today 😎
@cupricrafts4 жыл бұрын
@@jiejenn the files are saved in microsoft templates folder, unrelated to the active document.
@mistysword5 жыл бұрын
Thanks so much for all the effort! This saved my day
@andrewmarcou61643 жыл бұрын
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?
@ScottAlexander684 жыл бұрын
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.
@jiejenn4 жыл бұрын
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
@ScottAlexander684 жыл бұрын
@@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.
@jiejenn4 жыл бұрын
@@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.
@ScottAlexander684 жыл бұрын
@@jiejenn Don't have much experience at all. That would be great and I am going to do some reading too lol.
@undrawingend2 жыл бұрын
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?
@jiejenn2 жыл бұрын
Yeah, it is possible.
@YippeeKanYe5 жыл бұрын
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.61184 жыл бұрын
Great tutorial. Thank you!!
@missyg31835 жыл бұрын
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!
@jiejenn5 жыл бұрын
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.
@StuartHough5 жыл бұрын
same issue here
@StuartHough5 жыл бұрын
I fixed this by unselecting the 'preview results' option in word. It then worked fine!
@julianspb63295 жыл бұрын
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
@jiejenn5 жыл бұрын
Check your code to see if there are any typos.
@parniunplugged70234 жыл бұрын
@@jiejenn I also got same error. Its something to do with SQL Statement.
@MrWarrentierney4 жыл бұрын
Amazing! You are my hero!
@rinarahmawati94723 жыл бұрын
It's magic 😍
@condee2894 жыл бұрын
Many thanks, it works.!!!
@zarinamustapha86045 жыл бұрын
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
@jiejenn5 жыл бұрын
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.
@romellamarie56084 жыл бұрын
@@jiejenn i have the same problem with Zarina, and I'm running Windows. help?
@romellamarie56084 жыл бұрын
i.m using word 2013 .. is there a different?
@danwilson48604 жыл бұрын
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
@Prasadavajjhala4 жыл бұрын
legend :) thank you
@ashishyadavhr4 жыл бұрын
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?
@jiejenn4 жыл бұрын
Well you can, but depends on the document content organization. Are the pages number consistent for each file? or the page number varies.
@robertanderson99153 жыл бұрын
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.
@capt3365 жыл бұрын
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?
@jiejenn5 жыл бұрын
Not sure if it follow. Can you be more specific.
@ngrant88225 жыл бұрын
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?
@jiejenn5 жыл бұрын
| 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 Жыл бұрын
Facing a problem that once merge and the doc / PDF was empty but the PFD file name was correct, any idea?
@jiejenn Жыл бұрын
Makes sure your PDF content is extractable. If it is an image or encrypted, then it may not work.
@susannescherer71822 жыл бұрын
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?
@jiejenn2 жыл бұрын
Hard to tell without looking at your files. One common cause is due to margin is not set correctly.
@susannescherer71822 жыл бұрын
@@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
@yogeshdesai30494 жыл бұрын
Thanks its very helpful kindly share the another vdo for all records save in one pdf format
@abdulwahedcatran83495 жыл бұрын
Thank you so much please how to add a picture to the file
@jiejenn5 жыл бұрын
I'm not following your question.
@abdulwahedcatran83495 жыл бұрын
@@jiejenn Let's say we have a logo folder for each client and we want to put this image on the customer's message
@niloofarmaleki35734 жыл бұрын
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?
@jiejenn4 жыл бұрын
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"")"
@niloofarmaleki35734 жыл бұрын
@@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?
@nullhas5 жыл бұрын
Hi Jenn, Pls advise, how to select rows to merge. I do not want to delete previous data.
@Permik1235 жыл бұрын
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
@programming3042 жыл бұрын
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.
@jiejenn2 жыл бұрын
Once solution is to have a separate column containing the file name, and use that column as the file name instead.
@Master-dh3xl3 жыл бұрын
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.
@TatjanaKovalevica4 жыл бұрын
thank you, very useful!
@keithng64804 жыл бұрын
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?
@jiejenn4 жыл бұрын
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.
@jeremybautista51004 жыл бұрын
@@jiejenn Hi was this solved? I am having the same issue
@jeremybautista51004 жыл бұрын
Sorry not the same issue its just all the merges are just blank
@renyap34534 жыл бұрын
how do we set the file destination and file source using the open file dialogue box? thanks!
@jiejenn4 жыл бұрын
Maybe this link might help docs.microsoft.com/en-us/office/vba/api/excel.application.inputbox
@renyap34534 жыл бұрын
@@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)
@renyap34534 жыл бұрын
Its ok now. Ive done it. Thanks alot!
@jiejenn4 жыл бұрын
Cool. Glad you figured it out.
@renyap34534 жыл бұрын
@@jiejenn can you also give a video on how to do the mailmerge with dynamic tables?
@dharmeshy36224 жыл бұрын
Thank you, its very useful for me
@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 Жыл бұрын
Do you mind send to a fax machine?
@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 Жыл бұрын
To be honest, I am not sure. I haven't fax anything since 2010, so don't know what to tell you.
@diratanaya48894 жыл бұрын
Best trick, thanks very much
@LisaLevy-fk3cv8 ай бұрын
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?
@jiejenn8 ай бұрын
The error is most likely due to invalid file path is provided.
@91alezander4 жыл бұрын
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!
@jiejenn4 жыл бұрын
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.
@91alezander4 жыл бұрын
@@jiejenn Thank you!
@npaverico4 жыл бұрын
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?
@jiejenn4 жыл бұрын
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"
@hestertencate29802 жыл бұрын
@@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.khoerudin38164 жыл бұрын
thanks, very usefull, but how if want to save with two DataFields, example, name and date
@kethanchordia5 жыл бұрын
Amazing will save me a lot of time. Thank you. Subscribed for life :-)
@tomdenapoli53133 жыл бұрын
Will this work on a Mac (Office 16). So far, no love.
@林春梅-e9c4 жыл бұрын
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.
@jiejenn4 жыл бұрын
You can directly create the PDF without creating the word doc.
@UpYours1015 жыл бұрын
Any tips on how to implement this with a variable list. Eg product1, product2 (if exists), ... ?
@jiejenn5 жыл бұрын
Never thought of that before. This is interesting, let me experiment a little bit and will get back to you.
@jiejenn5 жыл бұрын
Hey there, I think I figured it out but cause give me a specific example.
@UpYours1015 жыл бұрын
@@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
@thatdudewithachannel4 жыл бұрын
What if you have multiple letters for the same person? Could a file contain multiple letters for the same person?
@lashadolenjashvili97754 жыл бұрын
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?
@jiejenn4 жыл бұрын
Do you mean Windows publisher?
@lashadolenjashvili97754 жыл бұрын
@@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.
@kazisazzad92575 жыл бұрын
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.
@jiejenn5 жыл бұрын
To avoid saving the word file, I think you can just comment out the line that saves the word file.
@kamiwasielewski11192 жыл бұрын
Hi, I am able to produce word and PDF but both file are empty ) no words insite. Can someone help.
@Garlic-d4t5 жыл бұрын
Thank you so much!!
@michaelmassette56914 жыл бұрын
I was able to run this but the word docs and PDF files that were created are blank. any ideas?
@jiejenn4 жыл бұрын
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.
@michaelmassette56914 жыл бұрын
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.
@michaelmassette56914 жыл бұрын
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!!
@tysutton91604 жыл бұрын
Hi Jie, The documents are created with the files saved with the correct names however the document itself is blank. Thoughts?
@eduardostewart4124 жыл бұрын
same
@tysutton14174 жыл бұрын
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!
@eduardostewart4124 жыл бұрын
@@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).
@thomaskenny63935 жыл бұрын
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.
@jiejenn5 жыл бұрын
Without looking at your code I can only guess your file path is missing a slash.
@thomaskenny63935 жыл бұрын
@@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
@thomaskenny63935 жыл бұрын
@@jiejenn Ohhh are you saying my FOLDER_SAVED As String was missing a slash?
@jiejenn5 жыл бұрын
@@thomaskenny6393 check your FOLDER SAVED variable value, I think it is indeed missing a slash.
@samanthawakefield88312 жыл бұрын
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.
@jiejenn2 жыл бұрын
Hi Samantha, I charge a fee of $10 to troubleshoot. If you are interested please let me know.
@emiliazuloaga36024 жыл бұрын
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
@jiejenn4 жыл бұрын
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.
@abdulbaig20994 жыл бұрын
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.
@jiejenn4 жыл бұрын
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:=""
@abdulbaig20994 жыл бұрын
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
@michaelfaw5 жыл бұрын
I do follow the step that you give. But why the result is blank document and pdf? any idea about this issue?
@jiejenn5 жыл бұрын
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.