excel - A couple of questions about Word macros -
I need to get a list of names from Excel and insert them into a Word document, a document printing per name. Some text in the document and a bookmark named "name" The code is below.
First, if I want to know how long is the list of names in Excel spreadsheets and grab that, instead of hardcoded numbers is possible.
Second, I do not understand how I am already inserting it inside the document. . When I enter text in a bookmark, it gets attached after the bookmark, so if I keep adding names, they all stack together
It may be clear with the code:
sub-insertar_nombre () Dim Excel Excel.Application dim Planilla Excel.Workbook dim Hoja Excel.Worksheet set excel = CreateObject as in the form of ("Excel.Application") Dim file name String dim fname as application with Application.FileDialog (msoFileDialogOpen). AllowMultiSelect = false .Title = "S Eleccionar Documento de Excel ".Show the selected files filename = fname Planilla = Excel.Workbooks.Open (file name) set to Hoja = Planilla.Worksheets (1) in the form of a slow node in the next end for each fname 10 For calculation, string = 2 for nbro = Hoja.Cells (, count 1) .Value ActiveDocument.Bookmarks ("name"). Range.Text = Nibbles ActiveDocument.PrintOut Next End Sub
Forgive me if this code is OBV wrong or something, I'm starting with this.
I have a list of names from Excel and insert them into a Word document, per name Printing a document.
Why do not you simply use the mail merge feature?
Comments
Post a Comment