Using macro to save to network location

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

Using macro to save to network location

Post by MATT.B »

I would like to create an open office macro to save to a network location. normally in windows explorer you would type \\wolv54-pc\Documents\ to get to the folder i want to save in.
I have been having trouble completing this task. so i have been using a workaround i have oo save in a folder and each time the computer starts the folder is transferred to the network location using a windows script.
my current code

Code: Select all

Sub TEMPSAVE
        Dim args1(2) as new com.sun.star.beans.PropertyValue
        args1(0).Name = "Zoom.Value"
        args1(0).Value = 100
        args1(1).Name = "Zoom.ValueSet"
        args1(1).Value = 28703
        args1(2).Name = "Zoom.Type"
        args1(2).Value = 0
        Dim args2(1) as new com.sun.star.beans.PropertyValue
        Dim Arg(0) as new com.sun.star.beans.PropertyValue
        url = ConvertToUrl("C:\NetShare\Est Pdf\TEMP.ods")
        oDoc.StoreAsUrl(url,Array())
'ret& = Msgbox ("READY FOR EDIT", 10 + 1, "Information")
    End Sub
code i tried but crashes oo

Code: Select all

        url = ConvertToUrl("\\wolv54-pc\documents\TEMP.ods")
        oDoc.StoreAsUrl(url,Array())
any help or advice would be appreciated
OpenOffice 4.1.1 ON WINDOWS 7 64
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: using macro to save to network location

Post by RoryOF »

My standard solution is, at boot, to automatically map the network folder to a folder on my computer. All files in the target folder now appear as local on my computer, but are actually stored on a network device.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: using macro to save to network location

Post by Villeroy »

Map a drive letter to the network share.
Or use a real programming language. Basic is past century.
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
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

Re: using macro to save to network location

Post by MATT.B »

Villeroy wrote:Map a drive letter to the network share.
Or use a real programming language. Basic is past century.
I mean using another language is an option I just don't know the others.
what one would you suggest to get this job done?
OpenOffice 4.1.1 ON WINDOWS 7 64
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: using macro to save to network location

Post by RoryOF »

Python might be quickest in which to find some suitable code.

With apologies to Villeroy, have you checked the two Andrew Pitonyak works? It is very possible he has dealt with the problem (in BASIC!).
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using macro to save to network location

Post by RoryOF »

In https://www.pitonyak.org/AndrewMacro.odt listing 5.103 Andrew Pitonyak makes reference to a setting needed for connection to a network.

A quick search did not find any other useful reference to a network connection in this or his other main document.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Using macro to save to network location

Post by Villeroy »

That listing connects to a running office program so you can control that remote office by means of macro code. It does not provide access to a Windows file system unless you want to load the file on the remote computer. I thought of something like https://pypi.org/project/pysmb/ , a Python library to access Windows stuff like \\Server\path\file.xyz

Mapping a network resource to a drive letter is very easy. Then you can access the files on driver Z: just like the files on any other drive.
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
Post Reply