Rukes

Untitled

Jul 20th, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Button1_Click()
  2. Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
  3. myFile = "C:\Users\rukes\Desktop\vbapdf\in.txt"
  4. Open myFile For Input As #1
  5. Do Until EOF(1)
  6.     Line Input #1, textline
  7.     text = text & textline
  8. Loop
  9. Close #1
  10. Call saveBase64ToPDF(text)
  11. End Sub
  12.  
  13. Sub saveBase64ToPDF(bs As String)
  14.     Dim strTempPath As String
  15.     Dim b64test As String
  16.     b64test = bs
  17.     ' zde si nastavte cestu, kam se má PDF uložit, aktuálne do slozky, kde je tento soubor
  18.    ' dalsi moznost:
  19.    ' strTempPath = "C:\data\file.pdf"
  20.    strTempPath = ThisWorkbook.Path & "\temp.pdf"
  21.     Open strTempPath For Binary As #1
  22.        Put #1, 1, DecodeBase64(b64test)
  23.     Close #1
  24. End Sub
  25.  
  26. Private Function DecodeBase64(ByVal strData As String) As Byte()
  27.     Dim objXML As Object 'MSXML2.DOMDocument
  28.    Dim objNode As Object 'MSXML2.IXMLDOMElement
  29.    Set objXML = CreateObject("MSXML2.DOMDocument")
  30.     Set objNode = objXML.createElement("b64")
  31.     objNode.DataType = "bin.base64"
  32.     objNode.text = strData
  33.     DecodeBase64 = objNode.nodeTypedValue
  34.     Set objNode = Nothing
  35.     Set objXML = Nothing
  36. End Function
  37.  
Add Comment
Please, Sign In to add comment