Hi,
Just to start, i'm new with VBA and i'm having a hard time understanding the code. I got a good share done with code I found online. But now I want to do something and I can't find what i'm looking for.
Second my native language is Dutch so if my english doesn't make sense. I do apologise up front, i'm doing the best i can
If you can give me a direction where to look, I would already be glad. I searched the database but I couldn't find the information i needed. I hope someone will be able to help me out.
What i did was build a UserForm to enter data like the name of a project, the project owner, etc. This information can be inserted. I can recall the form, have the form read the bookmarks again, edit the information and insert the data back into the document. Which all works like a charm. The next step is to read these bookmarks into another Word file. In my company we make different document where we need the same information over and over again.
What i like to do is be able to open a new document (which are all standardised documents) let a UserForm pop up. Let me choose another document and have it read the bookmarks in that document. So the information that is already in the other document is inserted in this new Userform. So we don't have to fill out the same fields over and over again. I don't want it to be send directly to the bookmarks. But have the data inserted in to the fields in the userform so they can be edited.
I know there is a way but i have no clue how to get there.
This is what I have but it only opens the other document but doesn't read the bookmarks.
Also now it is a set document and i want is to give the user the choice of which document to read. I know I need to name the bookmarks the same in every file which is fine. I'm importing the data in to the documents anyway.
Reason is that our files start with the number of the project so with each project the file name will be different. So a set document in the VBA code like the example is not an option.
Private Sub CommandButton12_Click() Dim strDocName As String strDocName = "Y:\03. Marketing\03. Documenten\Sjablonen\20230714 Sjablonen nieuw\01.Offerte met Macro's DEF 00-0 mme.dotm" Dim SrcDoc As Word.Document Dim DestDoc As Word.Document Set DestDoc = ActiveDocument Set SrcDoc = Documents.Open(strDocName) DestDoc.FormFields("Me.Ftitelof.Text").Result = SrcDoc.FormFields("TITofferte").Result DestDoc.FormFields("Me.FprojectName.Text").Result = SrcDoc.FormFields("projectName").Result DestDoc.FormFields("Me.Freferentie.Text").Result = SrcDoc.FormFields("REFra").Result DestDoc.FormFields("Me.Fog.Text").Result = SrcDoc.FormFields("Opdrachtgever").Result End Sub