Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Agregar numeración de línea a un .docx con ActiveXObject('Word.Application')

Hola, quiero agregar la numeración de líneas al archivo .docx abierto antes de convertirlo a .pdf y realmente no encontré cómo hacerlo en el código, está convirtiendo mi archivo .docx a pdf pero también quiero agregar la numeración de líneas, estoy usando ActiveXObject con javascript para hacer eso en el servidor

 var obj = new ActiveXObject("Scripting.FileSystemObject"); var docPath = WScript.Arguments(0); docPath = obj.GetAbsolutePathName(docPath); var pdfPath = docPath.replace(/\.doc[^.]*$/, ".pdf"); var objWord = null; try { objWord = new ActiveXObject("Word.Application"); objWord.Visible = false; var objDoc = objWord.Documents.Open(docPath); var format = 17; objDoc.SaveAs(pdfPath, format); objDoc.Close(); WScript.Echo("Saving '" + docPath + "' as '" + pdfPath + "'..."); } catch(e){ WScript.Echo(e); } finally { if (objWord != null) { objWord.Quit(); } }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si desea automatizar Word pero no sabe cómo hacerlo en el código, comience a grabar una macro, haga lo que quiera, luego deje de grabar y revise el código. Debería poder averiguar lo que necesita del código generado.

Aquí hay un ejemplo de una macro grabada:

 Sub Macro1 With Selection.PageSetup With .LineNumbering .Active = True .StartingNumber = 1 .CountBy = 1 .RestartMode = wdRestartContinuous .DistanceFromText = wdAutoPosition End With .Orientation = wdOrientPortrait .TopMargin = InchesToPoints(1) .BottomMargin = InchesToPoints(1) .LeftMargin = InchesToPoints(1) .RightMargin = InchesToPoints(1) .Gutter = InchesToPoints(0) .HeaderDistance = InchesToPoints(0.5) .FooterDistance = InchesToPoints(0.5) .PageWidth = InchesToPoints(8.5) .PageHeight = InchesToPoints(11) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With End Sub

Basado en ese ejemplo, asumiría que su código necesitaría incluir esto para los números de línea:

 objDoc.PageSetup.LineNumbering.Active = true;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!