i am trying to have VBA open up a specific word document (this document is protected but has boxes where you are able to edit text). i will then need to fill out said word documents editable areas with variables in the excel document. i have no idea where to start with this code and was posting to see if this is possible and how i could do it.
Additional note. Would it be easier to have vba create a whole new word document in the code so it can just add in all the text?
Since there isn't any code. I'm not sure what stage you're at in this but, from how I read your question you have two ways to do this. Either have your vba code in the word document that opens an Excel file to read cells or have the excel document create a word document with information already filled out. I would recommend using Word to read Excel.
This Question has information about setting fill-able values in Word. There are also a lot of resources out there to find out how to get cell values and open excel documents using VBA.
All this being said. I would say you should probably look for alternatives to all of this. Such as powerapps connecting to an excel file or change your excel file to a SQLExpress database to use that in finding data. The reason I recommend this is because it's much more scalable.
Related
I´m currently building an excel userform, where you fill out textboxes in the form which then writes those inputs into excel sheet cells. After the form is being closed, that specific sheet is being saved as a pdf. Now since I don´t want to add the keywords in the metadata of the pdf after saving it, I have to add keywords to the excel file before the saving process, so that the pdf uses those same keywords. Until now, I gave those keywords with the code
ActiveWorkbook.BuiltInDocumentProperties("Keywords") = "example"
This worked pretty well. But it would be way easier and more automated, if I could fetch certain information, which is entered in the form, and use those as keywords. I have tried that with:
ActiveWorkbook.BuiltInDocumentProperties("Keywords") = UserForm1.TextBox1.Value
but that does not work. Does anyone know if there is a mistake or another way to do it?
THANK YOU!
I am trying to generate a Word document that consists of Excel information. When the Excel document updates I would like for the Word document to do the same.
I have managed to setup a template in Excel which carries over the information into Word seamlessly. The formatting is still a struggle though and if the Excel document changes I need to reproduce the whole Word doc from scratch again.
I am wondering whether it is possible to create the template in Word and "connect" it to the Excel (as the underlying information) easily using VBA?
What are some of the best practices or suggestions to try and go about doing something like this.
In Word, on the Insert tab, look at Insert Object. You have the option of inserting / linking part of the contents an Excel worksheet in the Word document. Once linked, whenever you open the Word document, its contents is automatically refreshed with the latest contents from the linked Excel worksheet.
The only thing that you have to be careful about with this solution, is that if you move your Excel files with respect to the Word document (to another folder), then when you open the Word document, Word will not be able to find the Excel documents. When implementing a solution like this, both the Word document and the linked Excel documents are typically kept / copied / moved together.
I have an Excel spreadsheet on a Sharepoint site that I would like to keep as read-only. However, my users will occasionally need to add small amounts of data, which I thought could be best stored in a small text file. I can read the text data into the Excel userform easily enough, and I can amend the text file with new data equally easy - but only if I have already checked the text file out. This doesn't work for other users of course. Is there some method of checking out a file - which isn't a workbook - out via Excel VBA, or will I have to switch to storing the updateable data in another workbook?
It is possible to use VBA to read textfiles. You can use this example for instance: https://www.excel-easy.com/vba/examples/read-data-from-text-file.html where you can read the data per line.
On this discussion it is well explained how to populate Word Templates from excel data using Bookmarks on Word.
In my case, I need to populate the template as many times as the Excel's rows are.
Attached you can find an example. Sorry if I don't add any VBA draft code, but I don't have any idea of how to set it up.
The excel table is:
The word template is:
And the result should be:
I have a .csv file which I can export and from which I need to copy data into word.
I know how to get the relevant data from Excel and format my .csv file with VBA, however I don't know how to get my data from that Excel file to Word.
Basically this is how a line of my formatted .csv file looks (I Got rid of all the info I don't need).
For clarification: 1st long nr. is personnel 2nd one is token.
And I need to fill that info into the following table in word (Not everything gets filled in).
And one extra thing, depending on the extention of the email address #mc or #lmc, I need a different file opened (Different languages). How would I best do that?
Possible algorithm:
In your Excel document, develop a VBA macro that
Copy data/elements from Excel document
Open your word document
Paste excel data to word document (to the places you want)
Save word document
Close word document
Here is some code for inspiration of how to do that.