Excel2latex

Version: 2004
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I'm trying to convert a table to latex but there's an error message that pops up each time: Compile error: sub or function not defined.  <br><br>What am I missing? The Excel2LaTeX.xla is in my Additional Tools folder and the macros are enabled. What more can I do? <br><br>Thanks,
1
didichou
5/16/2010 4:11:08 AM
mac.office.excel 1146 articles. 0 followers. Follow

8 Replies
1654 Views

Similar Articles

[PageSpeed] 58

Why did you not tell us WHICH Sub or Function?  Sorry, but we can't read
your screen from here!

That error means there is a piece missing from your macro.

When it occurs, the Visual Basic Environment should open, and the yellow
highlight will be resting on the offending line of code, which will be a
call to something that is not there.

You need to find out what that is, and replace it.

It may be that you are using VBA from a higher version of Excel which has
functions that 2004 does not have.  In which case you will have to code
around the function.

If you tell us which one it is, we may be able to help.

If the VBE does not appear when the error occurs, you may be dealing with
password-protected code.  Without the password, you can't go any further.

Hope this helps


On 16/05/10 2:11 PM, in article 59bb88aa.-1@webcrossing.JaKIaxP2ac0,
"didichou@officeformac.com" <didichou@officeformac.com> wrote:

> Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I'm
> trying to convert a table to latex but there's an error message that pops up
> each time: Compile error: sub or function not defined.
> 
> What am I missing? The Excel2LaTeX.xla is in my Additional Tools folder and
> the macros are enabled. What more can I do?
> 
> Thanks,

 --

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410 | mailto:john@mcghie.name


0
John_McGhie_
5/16/2010 4:26:23 AM
On 5/16/10 12:11 AM, didichou@officeformac.com wrote:
> Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel
> I'm trying to convert a table to latex but there's an error message that
> pops up each time: Compile error: sub or function not defined.
>
> What am I missing? The Excel2LaTeX.xla is in my Additional Tools folder
> and the macros are enabled. What more can I do?
>
> Thanks,
I do not know what Latex is, but I'll bet a whole lot that the authors 
of the addin did not allow for the possibility that it may work on a 
Mac. Your only alternative is to contact the authors and ask them to 
rewrite the addin so it will work on a Mac. (or ask therm to contact me 
and I will be happy to provide a quotation for the conversion.)

-- 

Bobgreenblattatmsndotcom
0
Bob
5/16/2010 10:15:46 AM
When the visual basic environment opens, it highlights the following line: Sub ConvertSelection(). I don't know how to code around that problem, so if you can help, it would be much appreciated!
0
didichou
5/16/2010 4:57:37 PM
On 5/16/10 12:57 PM, didichou@officeformac.com wrote:
> When the visual basic environment opens, it highlights the following
> line: Sub ConvertSelection(). I don't know how to code around that
> problem, so if you can help, it would be much appreciated!
I don't have a clue unless I can see all the code to figure out what is 
happening. Posting a single line does no good at all.

-- 

Bobgreenblattatmsndotcom
0
Bob
5/16/2010 11:28:40 PM
Are you SURE it's that line?

That IS the "Sub or Function" that it says is not defined...

Can you post the whole of the code in that block, down to the End Sub
statement?

Sorry mate, but this is NOT Twitter: I can't help you unless you provide
full detail of what's going on.  If you don't write a screenfull in here,
chances are, I don't have the details I need to help you solve your problem.

Cheers


On 17/05/10 2:57 AM, in article 59bb88aa.2@webcrossing.JaKIaxP2ac0,
"didichou@officeformac.com" <didichou@officeformac.com> wrote:

> When the visual basic environment opens, it highlights the following line: Sub
> ConvertSelection(). I don't know how to code around that problem, so if you
> can help, it would be much appreciated!

 --

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410 | mailto:john@mcghie.name


0
John_McGhie_
5/17/2010 9:52:52 AM
The first line is what's highlighted  <br><br>Sub ConvertSelection() <br>
&nbsp;&nbsp;Dim CellWidth As Integer    'Characters per Cell in output file <br>
&nbsp;&nbsp;Dim txt As String <br>
&nbsp;&nbsp;Dim txt2 As String <br>
&nbsp;&nbsp;Dim multicells As Integer <br>
&nbsp;&nbsp;Dim RangeToUse As Range <br>
&nbsp;&nbsp;Dim r As Object <br>
&nbsp;&nbsp;Dim FileName As String <br>
&nbsp;&nbsp;Dim i As Integer <br>
&nbsp;&nbsp;Dim j As Integer <br>
&nbsp;&nbsp;Dim pos As Integer <br>
&nbsp;&nbsp;Dim convertDollar As Boolean <br>
&nbsp;&nbsp;Dim booktabs As Boolean <br>
&nbsp;&nbsp;Dim tableFloat As Boolean <br>
&nbsp;&nbsp;Dim Indent As Integer <br>
&nbsp;&nbsp;Dim Original As Range <br><br>  Application.ScreenUpdating = False <br>
&nbsp;&nbsp;CellWidth = Val(frmConvert.txtCellSize) <br>
&nbsp;&nbsp;convertDollar = frmConvert.chkConvertDollar <br>
&nbsp;&nbsp;booktabs = frmConvert.chkBooktabs <br>
&nbsp;&nbsp;tableFloat = frmConvert.chkTableFloat <br>
&nbsp;&nbsp;Indent = Val(frmConvert.txtIndent) <br><br>  multicells = 0 <br>
&nbsp;&nbsp;Set Original = Selection <br>
&nbsp;&nbsp;Set RangeToUse = moveSelection 'move range to working sheet <br><br>  Range(&quot;a1&quot;).Select 'this is done to solve cosmetic problem. range is re-selected at the end <br>
&nbsp;&nbsp;TransferStylesTopLeft RangeToUse <br><br>  FullText = Space(Indent) + &quot;% Table generated by Excel2LaTeX from sheet '&quot; + ActiveSheet.name + &quot;'&quot; + vbLf <br><br>  If tableFloat Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) + &quot;\begin{table}[htbp]&quot;, True <br>
&nbsp;&nbsp;&nbsp;&nbsp;Indent = Indent + 2 <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) + &quot;\centering&quot;, True <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) + &quot;\caption{Add caption}&quot;, True <br>
&nbsp;&nbsp;&nbsp;&nbsp;Indent = Indent + 2 <br>
&nbsp;&nbsp;End If <br><br>  AddText Space(Indent) + &quot;\begin{tabular}{&quot; <br>
&nbsp;&nbsp;If booktabs Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Replace(GetColumnsFormat(RangeToUse), &quot;|&quot;, &quot;&quot;) <br>
&nbsp;&nbsp;Else <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText GetColumnsFormat(RangeToUse) <br>
&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;AddText &quot;}&quot;, True <br><br>  'Start checking top border <br>
&nbsp;&nbsp;Set r = RangeToUse.Rows(1) <br><br>  If booktabs Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) + &quot;\addlinespace&quot;, True <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) + &quot;\toprule&quot;, True <br>
&nbsp;&nbsp;Else <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText HorizontalBorder(r.Borders(xlTop).LineStyle, Indent) <br>
&nbsp;&nbsp;End If <br><br>  'Table contents: <br>
&nbsp;&nbsp;For j = 1 To RangeToUse.Rows.Count ' for each row <br>
&nbsp;&nbsp;&nbsp;&nbsp;Set r = RangeToUse.Rows(j) <br>
&nbsp;&nbsp;&nbsp;&nbsp;If (j = 2) And booktabs Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) + &quot;\midrule&quot;, True <br>
&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText Space(Indent) <br><br>    For i = 1 To r.Cells.Count  ' for each cell in row r <br><br>'      If multicells > 1 Then ' is this cell part of a multicolumn cell <br>
'        multicells = multicells - 1 <br>
'        GoTo nxt <br>
'      End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = r.Cells(i).Text <br><br>      'Check for special characters % and $ <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If convertDollar Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;\&quot;, &quot;\textbackslash &quot;) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;$&quot;, &quot;\$&quot;) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;_&quot;, &quot;\_&quot;) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;^&quot;, &quot;\^&quot;) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;%&quot;, &quot;\%&quot;) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;&amp;&quot;, &quot;\&amp;&quot;) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt = Replace(txt, &quot;#&quot;, &quot;\#&quot;) <br><br>      'Check for Font Styles <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If r.Cells(i).Font.Bold Then txt = &quot;{\bf &quot; + txt + &quot;}&quot; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If r.Cells(i).Font.Italic Then txt = &quot;{\it &quot; + txt + &quot;}&quot; <br><br>      'Check for multicolumns <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If r.Cells(i).MergeCells Then   'multicolumn cell <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;multicells = r.Cells(i).MergeArea.Columns.Count <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt2 = &quot;\multicolumn{&quot; + Str(multicells) + _ <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;}{&quot; + GetColumnsFormat(r.Cells(i)) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt2 = txt2 + &quot;}{&quot; + txt + &quot;}&quot; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddText txt2 <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If i < r.Cells.Count Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddText PadSpace(multicells * (3 + CellWidth) - 3 - Len(txt2)) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i = i + multicells - 1 <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else 'single cell <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddText txt <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If i < r.Cells.Count Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddText PadSpace(CellWidth - Len(txt)) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If i <> r.Cells.Count Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddText &quot; &amp; &quot; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;&nbsp;&nbsp;Next i 'cells in row <br>
&nbsp;&nbsp;AddText &quot; \\&quot;, True <br>
&nbsp;&nbsp;&nbsp;&nbsp;' Check for Border lines <br>
&nbsp;&nbsp;If Not booktabs Then <br>
&nbsp;&nbsp;&nbsp;&nbsp;AddText HorizontalBorder(r.Borders(xlBottom).LineStyle, Indent) <br>
&nbsp;&nbsp;End If <br>
&nbsp;&nbsp;Next j 'row <br><br>theend:  'Tabellenende <br>
If booktabs Then <br>
&nbsp;&nbsp;AddText Space(Indent) + &quot;\bottomrule&quot;, True <br>
End If <br>
AddText Space(Indent) + &quot;\end{tabular}&quot; <br><br>If tableFloat Then <br>
&nbsp;&nbsp;Indent = Indent - 2 <br>
&nbsp;&nbsp;AddText &quot;&quot;, True <br>
&nbsp;&nbsp;AddText Space(Indent) + &quot;\label{tab:addlabel}
0
didichou
5/17/2010 12:36:10 PM
OK, that is the comlete text of the sub, but I still can;t figure out 
what is wrong as i don't know how this sub is called, its context in the 
function, the global definitions etc.

If you really want help you need to post the ENTIRE add in code with a 
full description of what is happening and what errors you get.

I still maintain tha the authors of this functin did not alow for it to 
run on a Macintosh. They have probably used VB constructs that are OK in 
Windows but not a Mac. You best bet is to contact them and explain that 
is does not work and fins out their plans to correct it.

-- 

Bobgreenblattatmsndotcom
0
Bob
5/18/2010 12:42:24 AM
I need the other part of that, we didn't get it all down to the "End Sub"

So far, I can tell you that the construct below is wrong:

 'Check for multicolumns
      If r.Cells(i).MergeCells Then   'multicolumn cell
        multicells = r.Cells(i).MergeArea.Columns.Count
        txt2 = "\multicolumn{" + Str(multicells) + _
                "}{" + GetColumnsFormat(r.Cells(i))
        txt2 = txt2 + "}{" + txt + "}"
        AddText txt2
        If i
          AddText PadSpace(multicells * (3 + CellWidth) - 3 - Len(txt2))
        End If
        i = i + multicells - 1
      Else 'single cell
        AddText txt
        If i
          AddText PadSpace(CellWidth - Len(txt))
        End If
      End If
      If i  r.Cells.Count Then
        AddText " & "
      End If
    Next i 'cells in row


In each case where "If i" appears on a line by itself, there should be
something following it on that line, or the line is illegal in VBA.  Those
lines throw a compile-time error here.  That would produce your problem.

Send us the rest of it and we'll have another go.

Cheers


On 17/05/10 10:36 PM, in article 59bb88aa.5@webcrossing.JaKIaxP2ac0,
"didichou@officeformac.com" <didichou@officeformac.com> wrote:

> The first line is what's highlighted
> 
> Sub ConvertSelection()
>   Dim CellWidth As Integer    'Characters per Cell in output file
>   Dim txt As String
>   Dim txt2 As String
>   Dim multicells As Integer
>   Dim RangeToUse As Range
>   Dim r As Object
>   Dim FileName As String
>   Dim i As Integer
>   Dim j As Integer
>   Dim pos As Integer
>   Dim convertDollar As Boolean
>   Dim booktabs As Boolean
>   Dim tableFloat As Boolean
>   Dim Indent As Integer
>   Dim Original As Range
> 
>   Application.ScreenUpdating = False
>   CellWidth = Val(frmConvert.txtCellSize)
>   convertDollar = frmConvert.chkConvertDollar
>   booktabs = frmConvert.chkBooktabs
>   tableFloat = frmConvert.chkTableFloat
>   Indent = Val(frmConvert.txtIndent)
> 
>   multicells = 0 
>   Set Original = Selection
>   Set RangeToUse = moveSelection 'move range to working sheet
> 
>   Range("a1").Select 'this is done to solve cosmetic problem. range is
> re-selected at the end
>   TransferStylesTopLeft RangeToUse
> 
>   FullText = Space(Indent) + "% Table generated by Excel2LaTeX from sheet '" +
> ActiveSheet.name + "'" + vbLf
> 
>   If tableFloat Then
>     AddText Space(Indent) + "\begin{table}[htbp]", True
>     Indent = Indent + 2
>     AddText Space(Indent) + "\centering", True
>     AddText Space(Indent) + "\caption{Add caption}", True
>     Indent = Indent + 2
>   End If 
> 
>   AddText Space(Indent) + "\begin{tabular}{"
>   If booktabs Then
>     AddText Replace(GetColumnsFormat(RangeToUse), "|", "")
>   Else 
>     AddText GetColumnsFormat(RangeToUse)
>   End If 
>   AddText "}", True
> 
>   'Start checking top border
>   Set r = RangeToUse.Rows(1)
> 
>   If booktabs Then
>     AddText Space(Indent) + "\addlinespace", True
>     AddText Space(Indent) + "\toprule", True
>   Else 
>     AddText HorizontalBorder(r.Borders(xlTop).LineStyle, Indent)
>   End If 
> 
>   'Table contents:
>   For j = 1 To RangeToUse.Rows.Count ' for each row
>     Set r = RangeToUse.Rows(j)
>     If (j = 2) And booktabs Then
>       AddText Space(Indent) + "\midrule", True
>     End If 
>     AddText Space(Indent)
> 
>     For i = 1 To r.Cells.Count  ' for each cell in row r
> 
> '      If multicells > 1 Then ' is this cell part of a multicolumn cell
> '        multicells = multicells - 1
> '        GoTo nxt
> '      End If 
>       txt = r.Cells(i).Text
> 
>       'Check for special characters % and $
>       If convertDollar Then
>         txt = Replace(txt, "\", "\textbackslash ")
>         txt = Replace(txt, "$", "\$")
>         txt = Replace(txt, "_", "\_")
>         txt = Replace(txt, "^", "\^")
>       End If 
>       txt = Replace(txt, "%", "\%")
>       txt = Replace(txt, "&", "\&")
>       txt = Replace(txt, "#", "\#")
> 
>       'Check for Font Styles
>       If r.Cells(i).Font.Bold Then txt = "{\bf " + txt + "}"
>       If r.Cells(i).Font.Italic Then txt = "{\it " + txt + "}"
> 
>       'Check for multicolumns
>       If r.Cells(i).MergeCells Then   'multicolumn cell
>         multicells = r.Cells(i).MergeArea.Columns.Count
>         txt2 = "\multicolumn{" + Str(multicells) + _
>                 "}{" + GetColumnsFormat(r.Cells(i))
>         txt2 = txt2 + "}{" + txt + "}"
>         AddText txt2
>         If i 
>           AddText PadSpace(multicells * (3 + CellWidth) - 3 - Len(txt2))
>         End If 
>         i = i + multicells - 1
>       Else 'single cell
>         AddText txt
>         If i 
>           AddText PadSpace(CellWidth - Len(txt))
>         End If 
>       End If 
>       If i  r.Cells.Count Then
>         AddText " & "
>       End If 
>     Next i 'cells in row
>   AddText " \\", True
>     ' Check for Border lines
>   If Not booktabs Then
>     AddText HorizontalBorder(r.Borders(xlBottom).LineStyle, Indent)
>   End If 
>   Next j 'row 
> 
> theend:  'Tabellenende
> If booktabs Then 
>   AddText Space(Indent) + "\bottomrule", True
> End If 
> AddText Space(Indent) + "\end{tabular}"
> 
> If tableFloat Then
>   Indent = Indent - 2
>   AddText "", True
>   AddText Space(Indent) + "\label{tab:addlabel}

 --

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410 | mailto:john@mcghie.name


0
John_McGhie_
5/18/2010 10:26:47 AM
Reply:

Similar Artilces:

Excel2latex
Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I'm trying to convert a table to latex but there's an error message that pops up each time: Compile error: sub or function not defined. <br><br>What am I missing? The Excel2LaTeX.xla is in my Additional Tools folder and the macros are enabled. What more can I do? <br><br>Thanks, Why did you not tell us WHICH Sub or Function? Sorry, but we can't read your screen from here! That error means there is a piece missing from your macro. When it occurs, the Visual Basic Environm...