ODoc.FormFields(“Name”).Result = ThisWorkbook.Sheets(“Offerte”).Range(“B” & LastRow).Value ‘Textbox ODoc.FormFields(“Numero_Offerta”).Result = ThisWorkbook.Sheets(“Offerte”).Range(“A” & LastRow).Value ‘Textbox LastRow = ThisWorkbook.Sheets(“Offerte”).Cells.SpecialCells(xlCellTypeLastCell).Row SDocName = (ThisWorkbook.Path & “/modello_offerta.dotx”) Set oApp = CreateObject(“Word.Application”)
If Err.Number 0 Then ‘Word isn’t running so start it Set oApp = GetObject(, “Word.Application”) ‘See if word is already running ‘Requires a reference to the Word object library I’ve figured that word file is opened every two times, not alwaysĬlick again on the macro button –> open word, open file, filling text, save file renamed, everything ok
I’ve adjusted the code for my purpose, I have to retrieve the last row of an excel and fill the template word, then save with another name. ODoc.FormFields("CheckboxName").CheckBox.Value = True 'Checkbox Error_Handler_Exit:Įnd Sub Form Field MS Access VBA Programming MS Excel VBA Word 7 responses on “ VBA – Word – Update/Fill-in Document Form Fields” ODoc.FormFields("TextboxName").Result = "NewValue" 'Textbox SDocName = "YourWordDocToOpenFullPathAndExtension" Set oApp = CreateObject("Word.Application") If Err.Number 0 Then 'Word isn't running so start it Set oApp = GetObject(, "Word.Application") 'See if word is already running 'Requires a reference to the Word object libraryĭim sDocName As String On Error Resume Next It may not be sold/resold or reposted on other sites (links ' copyright notice is left unchanged (including Author, Website and ' Copyright : The following may be altered and reused as you wish so long as the ' Purpose : Update/Fill-in a Word document's form fields VbCritical, "An Error has Occurred!" End If Resume Error_Handler_Exit "Error Description: " & Err.Description, _ "Error Number: " & Err.Number & vbCrLf & _ MsgBox "The following error has occurred." & vbCrLf & vbCrLf & _ MsgBox "The specified file '" & sDocName & "' could not be found.", _ Set oDoc = Nothing Set oApp = Nothing Exit Sub ODoc.FormFields( "CheckboxName").CheckBox.Value = True 'Checkbox ODoc.FormFields( "TextboxName").Result = "NewValue" 'Textbox SDocName = "YourWordDocToOpenFullPathAndExtension" Set oDoc = oApp.Documents. 'Requires a reference to the Word object library Dim oApp As Object 'Word.Application Dim oDoc As Object 'Word.Document Dim sDocName As String On Error Resume Next Set oApp = GetObject(, "Word.Application") 'See if word is already running If Err.Number 0 Then 'Word isn't running so start it Set oApp = CreateObject( "Word.Application")
It may not be sold/resold or reposted on other sites (links ' back to this site are allowed). ' Website : ' Purpose : Update/Fill-in a Word document's form fields ' Copyright : The following may be altered and reused as you wish so long as the ' copyright notice is left unchanged (including Author, Website and ' Copyright).
There are various programs for creating and editing PDF files among the best is PDFelement.'- ' Procedure : UpdateDoc ' Author : CARDA Consultants Inc.
Also, PDF is the best format for creating online content and archiving files due to these benefits, the Portable Document Format is extremely popular worldwide. doc format when it comes to printing high-quality documents. PDF: which was invented by Adobe: and Word DOC are both universally accepted formats for documents. PDF, alternatively known as Portable Document Format, is a file format employed in presenting as well as exchanging documents dependably, without the need for software, hardware, or any operating system. Also, owing to the numerous benefits of PDF over DOC format, a few of which have been mentioned above, PDFelement is the perfect option to create a fillable form. It is the best tool for digitizing your paperwork and accelerating how you create, sign as well as prepare PDF documents. PDFelement offers users a fully-loaded PDF solution, including amazing features for creating, editing, converting, and signing PDF documents: everything at an affordable price.