Save File as txt using VBA
I am looking to save a pdf file as plain text through VBA, however I am getting the error "Security Settings Prevent access to this property or method". I am using Acrobat 9.0 Standard. Please help!
Here is the code I am using in VBA:
Dim AcroXApp As Object
Dim AcroXAVDoc As Object
Dim AcroXPDDoc As Object
Set AcroXApp = CreateObject("AcroExch.App")
AcroXApp.Hide
Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")
AcroXAVDoc.Open strPDFPath, "Acrobat"
AcroXAVDoc.BringToFront
Set AcroXPDDoc = AcroXAVDoc.GetPDDoc
Dim jsObj As Object
Set jsObj = AcroXPDDoc.GetJSObject
jsObj.SaveAs strOutputFile, "com.adobe.acrobat.plain-text"
AcroXAVDoc.Close False
AcroXApp.Exit
You can try it with iText dll
It is open source!
This is in C# but in VB is the "same":
public string GetPdf(string _path) {
var sb = new StringBuilder();
var path = _path;
try
PdfReader reader = new PdfReader(path);
int n_pages = reader.NumberOfPages;
int i = 0;
for (i = 1; i <= 1; i++)
var pageBytes = reader.GetPageContent(i);
if (pageBytes != null)
var token = new PRTokeniser(pageBytes);
while (token.NextToken())
var tknType = token.TokenType;
var tknValue = token.StringValue;
if (tknType == PRTokeniser.TokType.STRING)
sb.Append(token.StringValue);
catch (Exception e)
return e.Message;
return sb.ToString();
Cheers =)
Similar Messages
-
I have a pdf file which contains text if i copy all text and paste them into notpad and save file as .txt Is it change the ascii value of text ?
How to know character's encoding is ASCII?
-
Convert .fmb and .rdf files to .txt using unix commands
I want to know how to convert .fmb and .rdf files to .txt using unix commands
Example ACCT_ACCOUNTS_ADMIN.fmb ---> ACCT_ACCOUNTS_ADMIN.txt
agent_balances.rdf ---> agent_balances.txt
NOTE: i don't want to use form builder or report builder.
is there anyone who can help me
Regards
HarshThanks it helped and Just to add little bit on it
for i in `ls *.fmb`
do
f60gen module=$i userid=$unpw forms_doc=yes batch=yes
done
Might help someone too.
Thanks -
Facing problem to Checkin and checkout file from starteam using vba
Hi,
Im trying to checkin and checkout file in starteam through vba. I have imported the
StarTeamSDK104.dll in reference in vba project and tried to accomplish my task.
I am able to locate the file, but not able to checkout/checkin the file. I am not sure how to use checkin/checkout function in vba. I am getting an error at the checkout code(hichlighted in bold in the below code). Also I was able to
do it in java but i want it in vba.
Could someone help me on this.
Below is the code im using.
Sub ST_Test()
Dim strAddress As String
Dim nPort As Long
Dim strUser As String
Dim strPassword As String
Dim strProjectName As String
strAddress = "Sample Address"
nPort = 1234
strUser = "Sample Username"
strPassword = "Sample Password"
strProjectName = "Sample Project"
Dim Factory As New StServerFactory
Dim Server As StServer
Set Server = Factory.Create(strAddress, nPort)
Server.Connect
Server.logOn strUser, strPassword
Dim project As StProject
Set project = FindProject(Server, strProjectName)
Dim view As StView
Dim finder As StStarTeamFinder
Dim Folder As Stfolder
Set view = project.DefaultView
Set Folder = view.RootFolder
For Each chk In Folder.getItems(Server.TypeNames.File)
Dim fileitem As StFile
Set fileitem = chk
If fileitem.Name = "Filename.txt" Then
fileitem.checkout(0,False,True,False )
End If
Next chk
End SubHi,
As for the checkout method, please refer to the following link:
http://msdn.microsoft.com/en-us/library/office/aa223821(v=office.11).aspx
The syntax is:
expression.CheckOut(FileName)
Jaynet Zhang
TechNet Community Support -
Is there a way to Update and SaveAs, an XFA form using VBA or similar ?
All:
Need help to auto-fill and auto-save PDFs using VBA or some other means.
I have created an XFA form using LiveCycle ES ( v8 ) with a few fields.
What I need to do is repeat these steps below for 200+ PDF forms
Open the blank PDF form
Update 3 fields
Save the PDF with a new name
My Excel VBA code so far ( ** Copied from another post ) where dFile = "C:\temp.pdf" and dAccount = "Any Account"
Sub rxOpenPDF_UpdateFields(dFile, dAccount )
Dim pdfApp As Acrobat.AcroApp, pdfPDDoc As Acrobat.AcroPDDoc, jso As Object
Dim str1$, bolOpen As Boolean, strFile$
Set pdfApp = CreateObject("AcroExch.App")
Set pdfPDDoc = CreateObject("AcroExch.PDDoc")
bolOpen = pdfPDDoc.Open(dFile)
Set jso = pdfPDDoc.GetJSObject
str1 = jso.getfield("Account_Name").Value ' Will appreciate if there is a way to set a field value
pdfApp.Exit
Set pdfApp = Nothing
Set pdfPDDoc = nothing
Set jso = Nothing
End Sub
Excel VBA is shutting down ( cannot recover ) when it runs the pdfPDDoc.Open statement
Any help will be very appreciated
Aubrey
I am on Windows XP,
In VBA, I have created Tool References to [Adobe Acrobat 9.0 Type Library]
Downloaded the Acrobat v9 SDK but am lost trying to locate any help for simple VBA.lrosenth,
Would I be able to Update & SaveAs with a newer version of LiveCycle ( does Adobe still have a LiveCycle line ) ?
I was looking at InDesign but am not sure if it has the functionality that I need ( i.e. create multiple forms from an Excel list)
.. also am unsure of the learning curve.
Aubrey -
Save file to database using WEBUTIL
Hi,
I have used webutil_file_transfer.Client_To_AS_with_progress to upload files from client to Application Server using Forms 10g
However, now i want to save file in database and not upload to database.
Apart from the problem, I was wondering if there is documentation available on WEBUTIL
Please helpI want to store the file in the database as a BLOB.
Earlier I was uploading to Application Server.
I had used webutil_file_transfer.Client_To_AS_with_progress to upload to Server,
I hope there is a procedure / function similar to Client_To_AS_with_progress in the webutil_file_transfer package -
Save File as SVG using Illustrator
Generous Helper,
I am trying to save the file as .SVG format using illustrator..
Openin in notepad the saved file shows the elements and attribute like:
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="800px" height="600px" viewBox="0 0 800 600" enable-background="new 0 0 800 600" xml:space="preserve">
<rect x="132.286" y="53" fill="none" width="161.429" height="17.857"/>
<text transform="matrix(1 0 0 1 132.2856 61.52)" font-family="'MyriadPro-Regular'" font-size="12">Name</text>
<rect x="137.286" y="87.286" fill="none" width="102.143" height="10.714"/>
</svg>
I like to see the elements and attributes like:
<g transform="translate(100,100)">
<text id="TextElement" x="0" y="0" style="font-family:Verdana;font-size:24"> Name !
<animateMotion path="M 0 0 L 100 100" dur="5s" fill="freeze"/>
</text>
</g>
The difference between both the files is
text id="TextElement" , so that I can use this as pointer for data to enter.
can someone tell me how I can achieve the code no# while saving the file as .SVG using Illustrator. While writing of my own .SVG file like code # 2 , I can write it and it is very well valid.
But I want illustrator write me the same style of code. I played around various options but every time I am getting the same style of code ( Code # one) using illustrator.
Thanks,Hi —
I'm a newbie to the forum reply system, but I try to check in for good info quite often.
If you are going to work with SVG and text input-output, you should be using the Variables palette and a schema architecture for your data. Start with reading the Help PDF "Data-driven graphics". There are a lot of considerations, up-front decisions and setup to prepare, but the pay-off is worth it. Also see the "About data sets" and "About variable libraries". Since this is an "open standard" there are element and property rules that are out on the XML site (you probably are already aware of these) and can help when swapping one element's name for another if you need to transform the output on the fly. You can actually build database exchanges without paying for a proprietary conversion application by using XML — if both databases are XML-friendly.
I'm sure if you go out to an XML forum, there are folks out there that can help with the output; once the file is saved as an SVG with the appropriate element names and setup. A helpful hint is not to save with Illustrator editing options. It saves two files then: one in SVG and the other in Illustrator, along with other errata. You can still edit the file without that option by simply opening it in Illustrator at any time, although you will see it has been "dumbed-down" a bit. SVG is cool, but not as mature as it should be and it does odd outputs when there are a lot of layers or clipping paths. If you are using an earlier version of Illustrator, the text can be fractured into individual letters and would need to be re-entered. The KISS method is the best route, although I have seen some awesome animations using SVG. Also, there are rumblings that CS3 and 4 cannot be opened in some other applications... I'm still researching that one.
Whenever I plan XML text interchange, I approach it as a separate project from the actual graphic like an extension that can surround it. It doesn't matter which you do first, the graphic layout and then the text interchange or visa versa... as long as you see them both as equally time-consuming for the initial set-up. Just because it is easy to type in the text and see it output, doesn't mean it will bend to your needs without a well-thought-out plan.
Hope this is of some help.
You may want to check out http://www.svgopen.org and http://www.svgopen.org/2009/ and the latest http://twitter.com/svgopen/ and http://www.planetsvg.com - see who might be represented from Adobe Illustrator (or not) since they are no longer supporting SVG (this year, anyway). -
How to save file in km using web dynpro abap
Hi Experts,
We have a requirement that file should be saved in a folder in km, the name of the folder should be the employee number.
Could you please tell me how to create folder with employee number in KM and store file in it using web dynpro abap.
Thanks and Regards,
Santhoshi.Thanks Naga Raju Meesala.
How come all these methods are deprecated...getEP5User
Also, since I am building a weddynpro DC, what is the proper way to include these jar files as Used DCs?
Now proceed in the same way with the variable PORTAL_HOME and add the following .jar files:
u2022 \lib\prtapi.jar The portal runtime APIs
u2022 \portalapps\com.sap.portal.usermanagement\lib\com.sap.security.api.ep5.jar The user management APIs of the Enterprise Portal 5.0 are deprecated, but still in use in SAP NetWeaver 04
u2022 \portalapps\com.sap.netweaver.bc.rf\lib\bc.rf.framework_api.jar KM Repository Framework APIs
u2022 \portalapps\com.sap.netweaver.bc.rf.service\lib\bc.rf.global.service.urlgenerator_api.jar Repository Framework Utility: URL Generator
u2022 \portalapps\com.sap.netweaver.bc.sf\lib\bc.sf.framework_api.jar Repository Framework: Repository Services
u2022 \portalapps\com.sap.netweaver.bc.util\lib\bc.util.public_api.jar Repository Framework Utilities -
Post Author: shark70
CA Forum: Desktop Intelligence Reporting
Hi
The vba below saves a file into excel then does some formatting but I need to use the saveas function to set a password for the excel file when opening.
The code in bold is where I am getting stuck
Any ideas on where I'm gioing wrong, I'm fairly new to vba unfortunately
Cheers
Sub SetantaDSAT()
ActiveDocument.RefreshActiveDocument.SaveAs ("K:\CLIENTS (LIVE)\Setanta\08. New Daily Reports\DTT and DSAT Case Type Reports\2008\May 08\") & Format(Date, "ddmmyyyy") & "_" & " TestSetanta DTT Case Type_Subtype Analysis" & ".xls"
Set xlsApp = CreateObject("Excel.Application")xlsApp.Visible = TruexlsApp.Workbooks.Open ("K:\CLIENTS (LIVE)\Setanta\08. New Daily Reports\DTT and DSAT Case Type Reports\2008\May 08\") & Format(Date, "ddmmyyyy") & "_" & " TestSetanta DTT Case Type_Subtype Analysis" & ".xls"
With xlsApp.Worksheets("DSAT Case Type").Activate.ActiveWindow.DisplayGridlines = False.Columns("B:B").EntireColumn.AutoFit.Columns("C:C").EntireColumn.AutoFit.ActiveWindow.Zoom = 75.ActiveWorkbook.SaveAs Filename:="C:\James\Check\Book22.xls", _ FileFormat:=xlNormal, Password:="test", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=FalseEnd With
End Subone other thought is that you can create text files with a batch process inside of acrobat. Advanced ---> Document Processing ----> Batch Processing.
Choose new sequence, give it a name
Step 1: Select Commands ----> Choose "execute javascript", then hit "Add." Click on "Execute Javascript" that was just added on the right, then hit the edit button and toss in the script below that I grabbed from the javascript samples (also, if your docs have multiple pages you'll need to embed the for loop into another for loop that cycles through each page). You'd also want to change the name of the saved txt file to the name of pdf you're doing it to. It shouldn't be that hard, but I'm guessing you're probably alot more familiar with VBA then javascript which is why you're choosing to do it from excel. I'm kind of in the same boat of having written a bunch of VBA, but not much javascript. I highly recommend investing some time into learning acrobat scripting b/c VB does have it's limitations when it comes to messing with PDF's.
* function to extract the text content of the current page and save to a file.
try {
var p = this.pageNum;
var n = this.getPageNumWords(p);
app.alert("Number of words in the page: " + n);
var str = "";
for(var i=0;i<n;i++) {
var wd = this.getPageNthWord(p, i, false);
if(wd != "") str = str + wd;
// save the string into a data object
this.createDataObject("whatever.txt",str);
// pop up a file selection box to export the data
this.exportDataObject("whatever.txt");
// clean up
this.removeDataObject("whatever.txt");
} catch (e) {
app.alert(e) -
Upload Excel File to SharePoint using VBA
Hi,
I copied and modified the code from a friend which he got it from this website forum.
This apprantely works for some people and not me. Please tell me what I am doing wrong.
Ignore xxxxxx part of the Sharepoint site. Nothing wrong with the site, i tried many combinations, but I get not response, not even an error.
Public Const HR_URL = "http://sun.xxxxxx.com/eng/st/Lists/Database%20Change% 20Request"
Sub test()
'Upload new Excel sheet to SharePoint
Call copyToSharePoint(HR_URL, ThisWorkbook.FullName)
End Sub
'''''''code block from Forum
Public Sub copyToSharePoint(sharepointURL As String, filePath As String)
'On Error GoTo errhandler
'sharePointUrl should not end in a "/"
'Initialize Variables
Dim LlFileLength As Long
Dim Lvarbin() As Byte
Dim LobjXML As Object
Dim LvarBinData As Variant
Dim LstrFileName As String, PstrFullfileName As String, PstrTargetURL As String
Dim fileName As String, lenFileName As Long
'Extract file name
lenFileName = Len(filePath) - InStrRev(filePath, "\")
fileName = Right(filePath, lenFileName)
'Check that the webUrl ends in an "/"
If Right(sharepointURL, 1) <> "/" Then
sharepointURL = sharepointURL & "/"
End If
'**************************** Upload binary files *****************
Set LobjXML = CreateObject("Microsoft.XMLHTTP")
PstrFullfileName = filePath
LlFileLength = FileLen(PstrFullfileName) - 1
' Read the file into a byte array.
ReDim Lvarbin(LlFileLength)
Open PstrFullfileName For Binary As #1
Get #1, , Lvarbin
Close #1
' Convert to variant to PUT.
LvarBinData = Lvarbin
PstrTargetURL = sharepointURL & fileName
' Put the data to the server; false means synchronous.
LobjXML.Open "PUT", PstrTargetURL, False
' Send the file in.
LobjXML.Send LvarBinData
Set LobjXML = Nothing
Exit Sub
errhandler:
If Err.Number = 53 Then
MsgBox "Excel was unable to create the HR file to submit to SharePoint. " & vbNewLine & _
"Please check that you are not running out of disk space and that no MS Office add-in is causing issues with Excel.", vbCritical, "File Error"
Exit Sub
Else
MsgBox "Your HR could not be submitted to SharePoint. The following error occurred:" & vbNewLine & _
"Error " & Err.Number & ": " & Err.Description, vbCritical, "Error Uploading to SharePoint"
Exit Sub
End If
End SubI have made the following code work successfully on a Windows 8 machine with the VBA executing from an Excel 2010 file and the file you want to upload going to a SharePoint 2010 site. If you don't need to use SP content types then simply
take that out of the code. Also, pay attention to the FieldInformation as the Field Display names and Field Internal names can sometimes be different. Cheers.
Public Sub copyDocToSP()
Const strLocalFile = "C:\temp\myLocalFile.pdf"
Const spBASE_URL = "https://thesharepointdomian/sites/yoursite/"
Const spDOC_LIB = "Your SP Doc Library Name"
Const spFILE_NAME = "FileNameOnceOnSharepoint.pdf"
Const spCONTENT_TYPE = "0x000000000000000000000000000000000000000"
Set ObjectStream = CreateObject("ADODB.Stream")
Set ObjectDOM = CreateObject("Microsoft.XMLDOM")
Set ObjectElement = ObjectDOM.createElement("TMP")
Set ObjectHTTP = CreateObject("Microsoft.XMLHTTP")
'Reading binary file
ObjectStream.Open
ObjectStream.Type = 1 'Type Binary
ObjectStream.LoadFromFile (strLocalFile)
BinaryFile = ObjectStream.Read()
ObjectStream.Close
'Conversion Base64
ObjectElement.DataType = "bin.base64" 'Type Base64
ObjectElement.nodeTypedValue = BinaryFile
EncodedFile = ObjectElement.Text
'Build request to load document
strURLService = spBASE_URL + "_vti_bin/copy.asmx"
strSOAPAction = "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"
strSOAPCommand = "<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" & _
"<soap:Body>" & _
"<CopyIntoItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" & _
"<SourceUrl>" + strLocalFile + "</SourceUrl>" & _
"<DestinationUrls>" & _
"<string>" + spBASE_URL + spDOC_LIB + "/" + spFILE_NAME + "</string>" & _
"</DestinationUrls>" & _
"<Fields>" & _
"<FieldInformation Type='Text' InternalName='Title' DisplayName='Title' Value='this is the title value' />" & _
"<FieldInformation Type='Choice' InternalName='Our_x0020_Status' DisplayName='Our Document Status' Value='Ready-to-distribute' />" & _
"<FieldInformation Type='Text' InternalName='ContentTypeId' DisplayName='Content Type ID' Value='" + spCONTENT_TYPE + "' />" & _
"</Fields>" & _
"<Stream>" + EncodedFile + "</Stream>" & _
"</CopyIntoItems>" & _
"</soap:Body>" & _
"</soap:Envelope>"
ObjectHTTP.Open "Get", strURLService, False
ObjectHTTP.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
ObjectHTTP.SetRequestHeader "SOAPAction", strSOAPAction
ObjectHTTP.Send strSOAPCommand
MsgBox (ObjectHTTP.responseText)
End Sub -
Numbers: Save file as xls using AppleScript
Hi all,
I need to remove all the external links from an Excel file. Tried to do this first using Automator and the Excel actions, but every time Excel opens one of the files it displays an error message that it's missing the external files and the Automator sequence is pauzed. Now I found out that if I open the Excel file with the Numbers app and save it again in the same file format (xls), the links are broken.
Now my question is how I can open the Excel files using Numbers and save them again as xls files. Since there are no Automator actions for Numbers, I'd like to accomplish this by using an AppleScript, which I'm very new to. Somebody help?
Thanks in advanceSome nice scripts for saving iWork files to Office formats were listed here.
I think the problem comes in with opening the Excel file with Numbers in a script. I believe this often brings up a Document Warnings window that requires user input, and I haven't seen any good way to deal with that in a script. -
How can I set a default save file for scans using the Solution Center?
Using Windows 7 - 64 bit. HP Photosmart Premuim C-309a All-In-One Printer.
Because of a Windows crash, I had to install a new drive and reload Windows. I also reloaded other software like the HP Solution Center & Drivers. My problem is that I can't find how to set a default folder for my scans. This is NOT mentioned in the user manual but it was originally accomplished by HP Tech Support when the printer was new. Can anyone relate how to set default folders for my scans?
Thanks.
Tango
This question was solved.
View Solution.Here is a document on how to scan through Windows 7.
http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&docname=c03476857
Click either solution center or the icon of the printer on your desktop. Here select "Scanner Actions" (or the analogous selection). When the window pops up from the HP software it should provide you with options for file type (.tiff, .pdf, .jpg) as well as resolution and media size. Here on this page there is also an option for you to go to the advanced options. Using this you can alter the default safe folder.
Let me know if that helps you out! -
Can't save file already in use or open
I've seen a lot of posts on this subject, so rather than replying to a specific one that may be on a different trail, I decided to open a new discussion. Lately I've had a lot of problems saving a file while in photoshop cs6 and getting this error. Sure, I can do a save as then delete the former file, but that doesn't solve the problem. Since it happens so often, I want the solution. Since the only application I have running when I get this error is Bridge, I closed Bridge when I got this error, and then I could save the file. In some of the discussion threads on this problem, I did see some reference to previews. I suspect this has to do with Bridge building previews or extracting previews or something related behind the scenes. I will keep monitoring this situation to see if closing Bridge always takes care of this problem. However, I never had this problem before, so I wonder if some of the latest updates created a new problem. I run Windows 7, and all the latest releases of ACR, PS, etc. Thoughts?
Do you have any layered TIFF's? It was a problem in Bridge as they keep caching. Do not know if the bug fixed yet.
Workaround is to turn off TIFF in edit/camera raw in Bridge. -
Is it possible to convert a jpg file to pdf using vba?
I have couple of image file in jpg format . I want to create pdf from these files using excel macro.
It is true for any format and the Acrobat SDK.
As this is the Adobe forum, we can't help you on other products. You would need to go elsewhere for that…. -
Saving a TextEdit file as .txt
This has been cross posted in 3rd generation Nano support, but I don't always get answers there.
I am having a problem seeing the notes I put on my Nano. I am composing and saving in TextEdit, but have been unable to save files in .txt, as specified in the Nano manual. When I did save using .txt, I got a warning saying I would also have to use .rtf. The files are saving, but I can't actually see their contents.
On my Nano, "enable disc use" is greyed out, but checked. The online documentation says this is O.K. and means the Nano disc is enabled.
Please let me know what I'm doing wrong. I really think the notes capability is a great feature. I want to use it.
Thanks!That saved it to .txt format, but the Ipod's still not seeing the contents of the file. Doh!
Thanks for your help, sig!
Maybe you are looking for
-
RFC response from Java mapping
Guys, I am RFC response in my java mapping as < & >. Any ideas why and how we can make it to get in xml < > format. The problem is parser does not identify this format. <?xml version="1.0" encoding="UTF-8"?><rfc:BAPI_COMPANYCODE_GETDETAIL.Respons
-
I am unable to create....
Hi All, i am working on <b>ABAP Proxies in XI(Client Proxy).</b> the weblogs posted by Ravikumar Allampallam. in this weblogs he has specified to <b>create message interface Proxy_Interface_OB using t.code SPROXY</b>. when i try to create new
-
How to trigger an event web service when a mail received in Exchange Server ?
Hi, I have a requirement of Triggering the event in Web-service with related data (Mail Details) whenever mail received in Exchange Server.. I have done R&D on this, but I couldn't find answer. Is there any possibility of triggering the service ? If
-
Hi, kernel task is troubling the daily usage of my 2013 macbook pro so I've search for a solution and I found this post : https://discussions.apple.com/thread/5520342?start=0&tstart=0 I've run the "Diagnostic test" linc devis is recommending and now
-
Editing a record using Objects SAP2007a
Hi I wrote a program using SAP objects to store contact information for one of our customers. I created a SAP object which handled the master table and 2 transactions tables There was very little code in the program but the screens are quite complic