Can CMD create MS Office files?



  • Hello!

    I'm writing a violin to automate the creation of projects where some catalogues are embedded, inside which other subcatelogues are built. In a catalogue, it would be preferable to automatically create Microsoft Office files. If possible, in the document ' s properties the author ' s creation, the title and topic.

    Can CMD create MS Office files? Like, "doc or "xls"? If not, what tools (cryptic languages, e.g. VBScript) can be used



  • You can try to generate the documents with the crypt. PowerShell

    Example of Word Document:

      $savepath="C:\work\MyDoc.docx"
      $word=new-object -ComObject "Word.Application"
      $doc=$word.documents.Add()
      $selection=$word.Selection
      #вставка текста
      $selection.TypeText((Get-Date))
      #вставка конца абзаца
      $selection.TypeParagraph()
      #вставка еще текста
      $os=Get-WmiObject -class win32_OperatingSystem
      $selection.TypeText("Operating System Information for $($os.CSName)")
      #получение свойств документа
      $os.properties | select Name | foreach -begin {$props=@()} -proc {$props+="$($_.name)"}
      #вывод их в документ как текст
      $selection.TypeText(($os | Select -Property $props | Out-String))
      $doc.SaveAs([ref]$savepath)    
      $doc.Close()
      $word.quit() 
    

    Here, an example can be found of the document: https://stackoverflow.com/questions/27781428/how-to-change-custom-properties-for-many-word-documents


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2