Save files with fields
Posted: Sun Mar 04, 2018 6:22 pm
Hi
My name is Steffen, and I hoping I can get some help here in this forum. In the last 4 days I have tried to save a text document with fields.
I have studying the article and the codes on viewtopic.php?t=20046#
I cannot get it to works as I would like to have it.
I have this code
Sub SaveWithFieldNames
On error goto EH
oDoc = ThisComponent
oTFS = oDoc.getTextFields
enum = oTFS.createEnumeration
While enum.hasMoreElements
oTF = enum.nextElement
Select Case oTF.Content
Case "ID" : N = oTF.Anchor.String
Case "SUBJECT" : A = oTF.Anchor.String
End Select
Wend
U = "-"
aray = Split(D,"/") 'convert slashes to dashes.
D = Join(aray,"-")
filename = N & "MEMORADIUM" & U & A & U ".odt"
url = ConvertToURL("C:\users\cat\documents\" & filename) 'Insert Your Desired Directory Path.
oDoc.StoreAsURL(url,Array())
oDoc.Modified = false 'avoid Save being called if doc closed without further edits.
End 'end normal execution.
EH: 'error handler.
MsgBox "You may have illegal file name character." & Chr(13)_
& Chr(13) & filename,,"AN ERROR OCCURRED"
End Sub
What I would like to have is follwing, pleace see the uploaded picture.
My name is Steffen, and I hoping I can get some help here in this forum. In the last 4 days I have tried to save a text document with fields.
I have studying the article and the codes on viewtopic.php?t=20046#
I cannot get it to works as I would like to have it.
I have this code
Sub SaveWithFieldNames
On error goto EH
oDoc = ThisComponent
oTFS = oDoc.getTextFields
enum = oTFS.createEnumeration
While enum.hasMoreElements
oTF = enum.nextElement
Select Case oTF.Content
Case "ID" : N = oTF.Anchor.String
Case "SUBJECT" : A = oTF.Anchor.String
End Select
Wend
U = "-"
aray = Split(D,"/") 'convert slashes to dashes.
D = Join(aray,"-")
filename = N & "MEMORADIUM" & U & A & U ".odt"
url = ConvertToURL("C:\users\cat\documents\" & filename) 'Insert Your Desired Directory Path.
oDoc.StoreAsURL(url,Array())
oDoc.Modified = false 'avoid Save being called if doc closed without further edits.
End 'end normal execution.
EH: 'error handler.
MsgBox "You may have illegal file name character." & Chr(13)_
& Chr(13) & filename,,"AN ERROR OCCURRED"
End Sub
What I would like to have is follwing, pleace see the uploaded picture.