"Data type mismatch" error

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
giavvns
Posts: 19
Joined: Thu Feb 25, 2010 8:38 pm

"Data type mismatch" error

Post by giavvns »

Hi all,

I've been using a function that gets me the comment inserted in a cell. So, the function's output is a string, Then I use built-in function 'len(...)' to get
the length of the string. The new output is an integer. I assign this to a variable already declared as integer and I get the message:

"inadmissible value or data type. Data type mismatch"

Here's the function that outputs comments from cells:

Code: Select all

Function CELL_NOTE(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns annotation text
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_NOTE = v.Annotation.getText.getString
   else
      CELL_NOTE = v
   endif
End Function
Here's where I get the error message:

Code: Select all

.......................
Dim iCol As Integer
Dim FstCol As Integer
Dim LstCol As Integer
Dim l As Integer
......................
l=len(cell_note(vSheet,lRowIndex&,iCol%)
......................
I'd appreciate any ideas on what is going on.
Thanks in advance and Merry Xmas to all!
OpenOffice 4 on SuSE opensuse-lean 15.0
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: "Data type mismatch" error

Post by Zizi64 »

Is it a StarBasic code based on the API funtion, or some MS VBA code?

Please upload the full code with an example .ods file.


A parenthesis is missing here:

Code: Select all

l=len(cell_note(vSheet,lRowIndex&,iCol%)
And really there is a type related problem. When the variable 'v' will be a Cell object, then it will have no any lenght property.

Code: Select all

CELL_NOTE = v
and

Code: Select all

v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: "Data type mismatch" error

Post by Villeroy »

It's my code and it works as advertised.
Attachments
cell_note.ods
(14.1 KiB) Downloaded 121 times
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