[Dropped] File saved to flash drive gives Disk Locked error

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
User avatar
alf50
Posts: 131
Joined: Sun Jun 13, 2010 2:55 pm

[Dropped] File saved to flash drive gives Disk Locked error

Post by alf50 »

File Saved to FlashDrive gives Disk Locked Error. ...(document, "uno:SaveAs", "", 0, args(2)) Method used.

Also tried FileSave() command, but apparently that only works with LibreOffice, not OpenOffice.

Also tried reformatting the Flash drive to MS-DOS FAT(32) format because I must share this x.ods file with pc users. Can drag and drop the file to the flash drive without issue, but using the macro generates the error.

The Code "Snippet" is shown below.

Code: Select all

	if CNT = "1" then
		msg = "Insert Transfer Flash Drive in USB port(F:)" & CHR(10)
		msg = msg & "then Click OK button Or Press Enter Key."
		msgbox msg
		dim args2(1) as new com.sun.star.beans.PropertyValue
		args2(0).Name = "URL"
		args2(0).Value = RSCINDrv & "/" & A
		args2(1).Name = "FilterName"
		args2(1).Value = "calc8"
		dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args2())
		goto BC2:	
	end if
Last edited by MrProgrammer on Wed May 07, 2025 9:36 pm, edited 1 time in total.
Reason: Dropped: No reply from alf50
OpenOffice 4.1.14 on Mac Catalina(10.15.7), RasPi4B (TwisterOS-8/2023update) & MS Wnds10
JeJe
Volunteer
Posts: 3064
Joined: Wed Mar 09, 2016 2:40 pm

Re: File saved to FlashDrive using macro gives Disk Locked error

Post by JeJe »

Try using converttourl for args2(0).Value

Edit: I assume RSCINDrv and A are defined string variables

Edit2: If your path is defined properly and it works with saving to the hard drive but not the USB, you could try saving to the hard drive then using FileCopy to transfer it and see if that works, noting that you can only use the FileCopy statement to copy files that are not opened.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
alf50
Posts: 131
Joined: Sun Jun 13, 2010 2:55 pm

Re: File saved to FlashDrive using macro gives Disk Locked error

Post by alf50 »

JeJe,
I can save the file to my hard drive just fine. But when I run a small OO Launching app to copy from my drive to the Flash Drive, I get the "Action not supported. Invalid procedure call." Error.

I am using a 2017 Mac Book Pro running OS X 13.4 and a PC running Vista. Any other suggestions?
OpenOffice 4.1.14 on Mac Catalina(10.15.7), RasPi4B (TwisterOS-8/2023update) & MS Wnds10
EthanCrawford
Posts: 1
Joined: Mon Apr 28, 2025 2:03 pm

Re: File saved to FlashDrive using macro gives Disk Locked error

Post by EthanCrawford »

It might be related to how the path is being handled between Mac OS and the USB drive. Mac OS sometimes applies different permissions or resource forks when dealing with external drives.
Before copying, check if the flash drive path is properly converted using ConvertToURL, similar to how it was suggested for SaveAs.
Example:

Code: Select all

Dim srcPath As String
Dim destPath As String

srcPath = "file:///Users/YourUserName/Documents/yourfile.ods"
destPath = "file:///Volumes/YourFlashDriveName/yourfile.ods"

FileCopy(ConvertFromURL(srcPath), ConvertFromURL(destPath))
Notice that FileCopy expects regular system paths, not URLs. So you might need ConvertFromURL instead of ConvertToURL before copying.

Also, ensure the flash drive is properly mounted and writable (sometimes Mac OS mounts USB drives as "read only" if it detects issues).
Helpful solution for fixing the dictionary issue—cleared things up quickly for me too. Always good to see active support. More info on the link: https://www.filemail.com/d/efzynxnwhbdwyrw
Locked