DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple same sheet names via user dialog

Hello everyone,

 

i have a dialog in wich i select different tests via combo boxes. Once i have selected a test, i select the channels from a channel list box that i want to view in the report. The report sheets should have the same names as the selected tests. Currently it is like this: i select test_A and channel X and a report with the sheet name test_A is created. If i select Test_B and any channel in the dialog, an additional sheet with the name Test_B is created. However, when i select Test_A again in the dialog, the new Test_A overwrites the old Test_A. This should not happen. Both tests should exist. For example: Test_A, Test_A_1 and continious.

 

Thanks a lot.

 

Greetings

Alexander 

0 Kudos
Message 1 of 4
(1,314 Views)

Hi Alexander,

 

If you try to rename a REPORT sheet with an already existing name, you will get an error. Example:

 

dim oSheet

set oSheet = Report.Sheets

oSheet(1).Name= "Test_A"

 

oSheet(3).Name= "Test_A"

 

Renaming sheet 3 is not possible, as expected.

I do not know how exactly you define your REPORT layout pages. But this is necessary to find the cause of this behavior.

 

Greetings

Walter

0 Kudos
Message 2 of 4
(1,292 Views)

Hello Walter,

 

thanks for your help.

 

Below is the dialog sud script where the report sheets with the test names are created and how it looks in the report.

 

In the report you can see the sheets with the names Test_A, Test_B and Test_C. But if i want to create the Test_A with another channel in the report, the first test_A is deleted and the new Test_A is created. However, i want to have both Test_A. Maybe it works that the second Test_A is then called Test_A_1 for example and continuous or similar?

 

Greetings

Alexander

 

Alexander_18_0-1666178871828.png

Alexander_18_1-1666179048132.png

 

'Festlegen des Sheet-Namens
report_name = ChooseTestBox.Text&"_"&ChooseSubtestBox.Text

' Uberpruefen, ob das der erste Report ist
if first_report then
'Neuen Report aufmachen
Call Report.NewLayout()

' Blatt zu Report hinzufuegen und "Blatt 1" loeschen
Set oMySheets = Report.Sheets
Call oMySheets.RemoveAll
Call oMySheets.Add(report_name)
Call oMySheets.Remove(1)

' Setzen des "first_report"-Flags auf False
first_report = False

elseif Report.Sheets.Exists(report_name) then

Set oMySheets = Report.Sheets
if 1 = oMySheets.Count then
Call oMySheets.Remove(report_name)
Call oMySheets.Add(report_name)
Call oMySheets.Remove(1)
else
Call oMySheets.Remove(report_name)
Call oMySheets.Add(report_name)
end if

else
' Ueberpruefen, ob es bereits ein Sheet mit diesem Namen gibt.
' Blatt zu Report hinzufuegen
Set oMySheets = Report.Sheets
Call oMySheets.Add(report_name)

end if

Call Report.Refresh()

 

0 Kudos
Message 3 of 4
(1,275 Views)

Hello Alexander,

 

here is a small test script that could solve this problem:

 

dim sTestID, oSheets, isNewTest 

sTestID   = "A"
isNewTest = false

if isNewTest then
  Report.LoadLayout(CurrentScriptPath & "DefaultSheet")
  set oSheets = Report.Sheets
  select case sTestID
    case "A"
      oSheets(1).Name = "Test_A"
    case "B"
      oSheets(1).Name = "Test_B"
    case "C"
      oSheets(1).Name = "Test_C"
  end select
else
  set oSheets = Report.Sheets
  call AddNewSheed(oSheets, sTestID)
end if

'-------------------------------------------------------------------------------
sub AddNewSheed(oSheets, sTestID)
  dim sSheetName
  select case sTestID
    case "A"
      sSheetName = GetNewSheetName(oSheets, "Test_A")
      call oSheets.Add(sSheetName)
    case "B"
      sSheetName = GetNewSheetName(oSheets, "Test_B")
      call oSheets.Add(sSheetName)
    case "C"
      sSheetName = GetNewSheetName(oSheets, "Test_C")
      call oSheets.Add(sSheetName)
  end select
end sub

'-------------------------------------------------------------------------------
function GetNewSheetName(oSheets, sSheetName)
  do while oSheets.Exists(sSheetName)
    sSheetName = sSheetName & "_1"
  loop
  GetNewSheetName = sSheetName
end function

 

Greetings

Walter

0 Kudos
Message 4 of 4
(1,272 Views)