Data base with links to Multiple files in a folder.

Creating a macro - Writing a Script - Using the API

Data base with links to Multiple files in a folder.

Postby D Soyars » Wed May 29, 2019 6:09 pm

Hi I am starting a bussiness that requires alot of coldcalls and follow ups. After i have a file generated is there a way to have a single spreadsheet with links to individual files and more than that auto fill as a templated file is created?
Say i save a file.
What i would like to happen is (a2) would be the file name. (B2) would be date created (c2) contents of templated new file (d3) would be follow up notes
With each file created these would be auto fill
Am I asking too much? Any thoughts on how to keep thousands of WO#s straight with follow up details in directory
OpenOffice 4.1.5 on Windows 10
D Soyars
 
Posts: 6
Joined: Wed May 29, 2019 5:40 pm

Re: Data base with links to Multiple files in a folder.

Postby Bidouille » Wed Jun 05, 2019 9:22 am

D Soyars wrote:there a way to have a single spreadsheet

A spreadsheet is not a database.
Use Base app.
User avatar
Bidouille
Volunteer
 
Posts: 285
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: Data base with links to Multiple files in a folder.

Postby Lupp » Wed Jun 05, 2019 2:09 pm

Term "Data Base" aside.

Not yet saved documents have no filenames. The document's .Url property is empty.
Having saved a document the first time it only got the URL by this action, and doesn't know it when the action is started.
To get the name/Url to be set in advance of saving you need to intercept the dialog by which the file gets its name (or next name).
It's different with .DocumentProperties like .CreationDate.

Anyway: If you not are familiar with programming based on the API you should drop this specific part of your project.

The code you need would be MUCH more complicated than the extremely simplified example below:
Code: Select all   Expand viewCollapse view
Sub onSaveDocument() REM Assigned to the 'Save Document' event.
REM Will NOT work in the requested way.
Can only save the Url the doc had in advance of the process.
doc = ThisComponent
sh1 = doc.Sheets(0)
a2  = sh1.getCellByPosition(0, 1)
b2  = sh1.getCellByPosition(1, 1)
If doc.Url<>"" Then
  a2.String = doc.Url
Else
  a2.String = doc.Title REM a kind of bad surrogate. Will most likely be "Untitled..."
End If
cd  = doc.DocumentProperties.CreationDate
With cd
  t = ((.Seconds/60+.Minutes)/60+.Hours)/24
  d = Date(.Year, .Month, .Day)
End With
b2.String = Format(d+t, "YYYY-MM-DD HH:MM:SS")
REM The output is made as text to avoid rare errors due to the day-zero-mess
REM or to the silly-date-formats-mess.
End Sub
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2529
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests