snipt

Ctrl+h for KB shortcuts

VB.net

VBScript – Open Word Document

1
2
3
4
5
6
7
8
Set WordObj = CreateObject("Word.Application")
'WordObj.Visible = False

Set WordDocument = WordObj.Documents.Open(pfad)

'WordDocument.PrintOut()
WordDocument.Close()
WordObj.Quit()
https://snipt.net/embed/a66416a2c575d5fceed56221e1cce054/
https://snipt.net/raw/a66416a2c575d5fceed56221e1cce054/
a66416a2c575d5fceed56221e1cce054
vb.net
VB.net
8
2016-09-27T17:14:54
True
False
False
/api/public/snipt/49228/
vb-open-word-document
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">Set</span> <span class="n">WordObj</span> <span class="o">=</span> <span class="n">CreateObject</span><span class="p">(</span><span class="s">&quot;Word.Application&quot;</span><span class="p">)</span> </span><span id="L-2"><a name="L-2"></a><span class="c">&#39;WordObj.Visible = False</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="k">Set</span> <span class="n">WordDocument</span> <span class="o">=</span> <span class="n">WordObj</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Open</span><span class="p">(</span><span class="n">pfad</span><span class="p">)</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c">&#39;WordDocument.PrintOut()</span> </span><span id="L-7"><a name="L-7"></a><span class="n">WordDocument</span><span class="p">.</span><span class="n">Close</span><span class="p">()</span> </span><span id="L-8"><a name="L-8"></a><span class="n">WordObj</span><span class="p">.</span><span class="n">Quit</span><span class="p">()</span> </span></pre></div> </td></tr></table>
vbs, word

VB.net

VB – Word Kopfzeile auslesen

sHeader = oDoc.Sections(1).Headers.Item(1).Range.Text
https://snipt.net/embed/eceefd1059961b9f5c8645aa025b20de/
https://snipt.net/raw/eceefd1059961b9f5c8645aa025b20de/
eceefd1059961b9f5c8645aa025b20de
vb.net
VB.net
1
2016-09-26T01:52:07
True
False
False
/api/public/snipt/49209/
vb-word-kopfzeile-auslesen
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="n">sHeader</span> <span class="o">=</span> <span class="n">oDoc</span><span class="p">.</span><span class="n">Sections</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="n">Headers</span><span class="p">.</span><span class="n">Item</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="n">Range</span><span class="p">.</span><span class="n">Text</span> </span></pre></div> </td></tr></table>
vb, word

JavaScript

Pure JS - Wrap Each Word in a <span>

1
2
3
4
5
6
//Used to create the faux small caps in the next snip ^^
var spanWrap = document.getElementsByClassName('sm-cap');
for(var i=0; i < spanWrap.length; i++) {
    var t = spanWrap[i];
	t.innerHTML = '<span>' + t.innerHTML . split(' ') . join('</span> <span>') +  '</span>';
}
https://snipt.net/embed/4a43cf14c355f88b428fc51dbf2f4427/
https://snipt.net/raw/4a43cf14c355f88b428fc51dbf2f4427/
4a43cf14c355f88b428fc51dbf2f4427
js
JavaScript
6
2016-09-28T16:52:05
True
False
False
/api/public/snipt/41176/
wrap-each-word-in-a-span
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1">//Used to create the faux small caps in the next snip ^^</span> </span><span id="L-2"><a name="L-2"></a><span class="kd">var</span> <span class="nx">spanWrap</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByClassName</span><span class="p">(</span><span class="s1">&#39;sm-cap&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">spanWrap</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">spanWrap</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">t</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s1">&#39;&lt;span&gt;&#39;</span> <span class="o">+</span> <span class="nx">t</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="p">.</span> <span class="nx">split</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="p">.</span> <span class="nx">join</span><span class="p">(</span><span class="s1">&#39;&lt;/span&gt; &lt;span&gt;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;&lt;/span&gt;&#39;</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
class, css, span, word, wrap

PHP

Exportar a Word con PHP

1
2
3
4
5
6
<?php
  header("Content-type: application/vnd.ms-word"); 
  header("Content-Disposition: attachment; filename=Reporte-Word.doc");
  header("Pragma: no-cache");  
  header("Expires: 0");  
?>
https://snipt.net/embed/9d2e7a5e2ce03d063938cc84c892e363/
https://snipt.net/raw/9d2e7a5e2ce03d063938cc84c892e363/
9d2e7a5e2ce03d063938cc84c892e363
php
PHP
6
2016-09-27T16:48:15
True
False
False
/api/public/snipt/28713/
exportar-a-word-con-php
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="nb">header</span><span class="p">(</span><span class="s2">&quot;Content-type: application/vnd.ms-word&quot;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">header</span><span class="p">(</span><span class="s2">&quot;Content-Disposition: attachment; filename=Reporte-Word.doc&quot;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">header</span><span class="p">(</span><span class="s2">&quot;Pragma: no-cache&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="nb">header</span><span class="p">(</span><span class="s2">&quot;Expires: 0&quot;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
exportar, word
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.