OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Save with auto file name

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
rhodestransit
Power User
Power User


Joined: 17 Mar 2011
Posts: 91

PostPosted: Wed Apr 18, 2012 5:54 am    Post subject: Save with auto file name Reply with quote

I am creating a form with text boxes that a user can complete and save to a folder.
To make the process easier is there a way i can have a save button that will save the form using a text field as the file name?
for example if the the form is an accident report it will user the name of the person who had the accident as the file name.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Wed Apr 18, 2012 8:54 am    Post subject: Reply with quote

My test file has a User Field named Name containing a name. This macro will not work with any other type of field.

Code:
Sub UserFieldAsFileName_Writer
On Error goto EH
oDoc = ThisComponent
TFM = oDoc.getTextFieldMasters
If TFM.hasByName("com.sun.star.text.fieldmaster.User.Name") then
  field = TFM.getByName("com.sun.star.text.fieldmaster.User.Name")
  filename = field.content
 Else MsgBox "No such field exists." : END
EndIf

url = ConvertToURL("C:\Users\John\Documents\" & filename & ".odt")'Insert Your Desired Directory Path.
oDoc.StoreAsURL(url,Array())
oDoc.Modified = false 'avoid Save being called if doc closed without further edits.
Exit Sub 'end normal execution.
EH: 'error handler.
MsgBox "You may have illegal file name characters in the file name shown below." & Chr(13)_
& Chr(13) & filename,,"AN ERROR OCCURRED"
End Sub
Back to top
View user's profile Send private message
rhodestransit
Power User
Power User


Joined: 17 Mar 2011
Posts: 91

PostPosted: Wed Apr 18, 2012 9:13 am    Post subject: Reply with quote

Thanks for the macro, I dont seem to have a field listed for "user" is that an add on?
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Wed Apr 18, 2012 10:43 am    Post subject: Reply with quote

Quote:
I dont seem to have a field listed for "user"
Insert > Fields > Other > Variables tab.
Back to top
View user's profile Send private message
rhodestransit
Power User
Power User


Joined: 17 Mar 2011
Posts: 91

PostPosted: Thu Apr 19, 2012 6:58 am    Post subject: Reply with quote

Ok thanks I found that now,
What do i put in the Value field?
I was hoping to get a box to use as a field on the form
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Thu Apr 19, 2012 7:27 am    Post subject: Reply with quote

Quote:
What do i put in the Value field?
Nothing.

The easiest way to get a box is Insert > Frame but you can also do View > Toolbars > Form Controls and use the Text Box.
Back to top
View user's profile Send private message
rhodestransit
Power User
Power User


Joined: 17 Mar 2011
Posts: 91

PostPosted: Thu Apr 19, 2012 12:53 pm    Post subject: Reply with quote

I dont know what in doing wrong, it will save but it will not save it with a file name.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Thu Apr 19, 2012 4:58 pm    Post subject: Reply with quote

Quote:
Quote:
What do i put in the Value field?
Nothing.
MY BAD! I thought I was in another tread.

You put what you want the file name to be in the Value field.
Back to top
View user's profile Send private message
rhodestransit
Power User
Power User


Joined: 17 Mar 2011
Posts: 91

PostPosted: Fri Apr 20, 2012 3:11 am    Post subject: Reply with quote

OK, thanks.
Its not going to work how i want then, I was hoping for a form with a save button that an office member can complete and save without having to insert fields.
Thanks for your help
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group