I am trying to add a form field or box to associate external PDF files with a particular record. Can anyone help?
Thanks.
Add file location or files to a record
-
- Posts: 11
- Joined: Fri Apr 03, 2020 5:14 pm
Add file location or files to a record
OpenOffice 4.1.7 on Windows 10
-
- Volunteer
- Posts: 1549
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Add file location or files to a record
On the General tab of the Push Button Properties dialog for a Push Button control on a Form set Action to Open document/web page.
Directly below is URL, place the filename with the complete path there and when the button is pressed it will open that document. Of course that requires a button for each pdf file, which isn't very practical if you have very many pdf files. In that case a macro is required to insert a filename and path stored in a field of your database table. Look here for an example
Hyperlink buttons for files, emails and other URLs
Directly below is URL, place the filename with the complete path there and when the button is pressed it will open that document. Of course that requires a button for each pdf file, which isn't very practical if you have very many pdf files. In that case a macro is required to insert a filename and path stored in a field of your database table. Look here for an example
Hyperlink buttons for files, emails and other URLs
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Posts: 11
- Joined: Fri Apr 03, 2020 5:14 pm
Re: Add file location or files to a record
Thanks so much for the help. I was hoping to create a table (associated to records) to store the files or file directories where the user can add entries and/or click on the files to open them or open a windows explorer window to view. Also, I would ideally like a dialog similar to "save as" to add the files names or directories to the table.
Any ideas would be extremely helpful.
Thanks.
Any ideas would be extremely helpful.
Thanks.
OpenOffice 4.1.7 on Windows 10
Re: Add file location or files to a record
You are right. My Python macro reads a file path or some valid URL from a database field and assigns the URL to a button which should open the resource when you click on it.
Here is a quick and dirty macro which opens a file-open dialog and writes the resulting file URL into a specified database field. Create a push button, assign the execute event to PickFileURL_Button AND write the name of the target column (name of table column, not the name of a form control) into the button's "Additional info". Take care that the button belongs to the right form or subform (the one having the target column).
Here is a quick and dirty macro which opens a file-open dialog and writes the resulting file URL into a specified database field. Create a push button, assign the execute event to PickFileURL_Button AND write the name of the target column (name of table column, not the name of a form control) into the button's "Additional info". Take care that the button belongs to the right form or subform (the one having the target column).
Code: Select all
REM ***** BASIC *****
Const cDialogTitle = "URL Button File Picker"
REM label and pattern for the file picker
Const cFilterLabel = "All Files (*)"
Const cFilter = "*"
REM ths defaults to the default document path of the office suite
REM use system notation C:\foo\bar\ or /home/user/foo/bar respectively
Const cInitPath = ""
REM write a file URL into a database field which is specified
REM in the "Additional info" field of a push button
Sub PickFileURL_Button(e)
sInitPath = convertToURL(cInitPath)
f = pickFile(cDialogTitle, sInitPath, cFilterLabel, cFilter)
if f <> "" then
oModel = e.Source.getModel()
s = oModel.Tag
oForm = oModel.getParent()
oColumn = oForm.Columns.getByName(oModel.Tag)
oColumn.updateString(f)
endif
End Sub
Function pickFile(sTitle$, sInit$, sFilterLabel$, sPattern$) As String
REM return a single file URL or ""
REM dialog starts at office default directory if sInit = ""
Dim oPicker, x()
oPicker = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
oPicker.setTitle(sTitle)
oPicker.setDisplayDirectory(sInit)
oPicker.setMultiSelectionMode(False)
oPicker.appendFilter(sFilterLabel, sPattern)
if oPicker.execute() then
x() = oPicker.getFiles()
pickFile = x(0)
endif
End Function
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice