View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Ludo Ludo is offline
external usenet poster
 
Posts: 74
Default Sort in hidden page crach

Op maandag 21 mei 2012 15:27:44 UTC+2 schreef Ludo het volgende:
Hi all,

I'm trying to sort a column (column T) in a hidden page (Add In
property = True).
I found some code on the net, but i always get a Error 9 message
(Subscript out of range (Error 9).
When i set the IsAddin property to False, everything's right, but as
soon as i set it back to True, i'll get the error message.

What am i doing wrong?

Using win XP & Excel2003 SP3.

here's the code i use:

'sort
With ThisWorkbook.Sheets("common settings").Range("T1" )
.Cells.Sort Key1:=Sheets("common settings").Range("T1"),
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers
End With

following 'version' of the code generates the same error:

'sort
With ThisWorkbook.Sheets("Common Settings").Range("T:T")
.Cells.Sort Key1:=Sheets("Common Settings").Range("T:T"),
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers
End With


Any help welcome.

Regards,
Ludo


Hi Garry,

Thanks for your answer.

I wrote a VBA application ( no, not the one for the Dymo450 Label Printer - if you remember ;)) running under Excel and need to fill-out several templates. In this application i opened - copy - paste the templates into the application, but because the IsAddin property is set, i needed to set it temporarely to False.
At that time, i wasn't aware that you can't add sheets into a Add-In at run time.
I'm not quite sure if i need to set the IsAddin property to False to change from printer, have to check the code.
So it's possible that i'm comming back with an other question on how to change from printer in a hidden workbook and print it out.

Now i'm extending this application, but i've learned a bit from this 'Add-In problem' so i don't add new pages into the Add-In, but keep them completely outside the Add-In. All the things i need in the Add-In are implemented in the Add-In at design time, so all the sheets i need and a graph.
Data that i need like common settings and unit specific data are stored in ..txt files that i load into the Add-In at run time.

As wtritten above, i hope that changing from printer doesn't give me problems with the Add-In. Fact here is that i need to print on white paper for the default production units and need to print on yellow paper for repaired units comming from customer service. Because VBA can't select a tray, and you can't define twice the same printer in windows, the first one with tray1 as default, the second one with tray2 as default, need i to print to 2 different printers.

Regards,
Ludo