I am trying to make "Planned Exec Date" field read only inTest Lab --> Execution Grid.
In Test Lab Module script --> TesSetTests_FieldCanChange Sub, I have added the following code:
TestSetTest_Fields.Field("TC_PLAN_SCHEDULING_DATE").IsReadOnly = True
But still date can be changed and added by writing in the field or choosing from calendar.
How do I make this field read only?
Thanks.
Sohel
I was able to resolve the problem by putting the code into TestSetTests_MoveTo sub.
Sub TestSetTests_MoveTo
On Error Resume Next
TestSetTest_Fields.Field("TC_PLAN_SCHEDULING_DATE").IsReadOnly = True
End Sub
Related
I want to automate GageR&R study in minitab.
I found code but the line mtbProject.Commands.Item(1).Outputs.Item(1).Graph.SaveAs.
Gives
Run time error:"IOutput: IOutput collection is empty and contains no valid output object"
Sub msa_macro()
'
' msa_macro Macro
'
'
Dim MtbApp As Mtb.Application
Dim mtbProject As Mtb.Project
Dim mtbWorksheet As Mtb.Worksheet
Set MtbApp = New Mtb.Application
Set mtbProject = MtbApp.ActiveProject
Set mtbWorksheet = mtbProject.ActiveWorksheet
MtbApp.UserInterface.Visible = True
MtbApp.UserInterface.DisplayAlerts = True
mtbProject.ExecuteCommand "Execute 'C:\Amir\DataAnalysis2\MSA_FixtureMill_STC049\MSA_STC049_BSM\Results_Files\readfileMinitab_test.mtb' 1."
mtbProject.Commands.Item(1).Outputs.Item(1).Graph.SaveAs "C:\Result_Files\grph1.png", True, GFJPEG
End Sub
The problem is, that you want to save the Outputs.Item(1) from Commands.Item(1). So you address the first command that you called, which is "Excecute … ", and this has no Output-Item. Therefore the IOutputs Collection for this Command-Item is empty.
The Output-Collection is defined as the Items of Outputs for each command. What you would want to do, is to save the first Output-Item of the command with which you created the graph.
It would be very helpful, if you could provide some information about your readfileMinitab_test.mtb. What are you doing in this .mtb file, is it also a macro-enabled file? I would guess, that you create the graph in this file?
If you want to save your graph as a .png, I guess you might need the MtbGraphFiletype GFPNGColor instead of GFJPEG. You also don´t need to save the file as grph1.png (just grph1 will suffice), as this is done automatically, because you tell Minitab to save it in a specific filetype.
You could also use the digit-code for the Filetypes (which is a little bit shorter). This would mean GFPNGColor = 3 and GFJPEG = 1. For some further information about this I recommend you the Minitab-Automation-Guide.
An example code could look as following:
'This is the first Command Minitab is executing
mtbProject.ExectueCommand "Execute <something>"
'This is the second Command Minitab is executing
mtbProject.ExecuteCommand "Boxplot C" & CStr(i as Integer)
'We want to Save the Graph, which we created with Command 2. We created one graph with
'this Command, to we only have 1 Output.
mtbProject.Commands.Item(2).Outputs.Item(1).Graph.SaveAs <path as String>, True, 3
Thanks Florian. Yes you are right, I figured it out that I am trying to read the output of the wrong command.
I wanted to execute a sequence of 'Gage R&R' commands and to save an output graph. It is completed now.
Thanks again for the helping answer.
I have this code:
Public channel As Long
Sub Button1_Click()
MsgBox "all is OK"
' Application.ActiveCell.Font.Bold = True
channel = Application.DDEInitiate("Excel", "System")
MsgBox "Conversation started"
End Sub
Why DDEInitiate expression gives error 13?
The registry keys shown in the office-watch blog mentioned by #VincentG were only relevant for Writer. Excel has its own set of keys (which one can check using Sysinternals ProcMon, both when Excel starts, and when DDEInitiate is called from VBA), which are at least:
In HKCU\SOFTWARE\Microsoft\Office\16.0\Excel\Options - DDEAllowed:REG_DWORD=1
In HKCU\SOFTWARE\Microsoft\Office\16.0\Excel\Security - DisableDDEServerLaunch:REG_DWORD=0, DisableDDEServerLookup:REG_DWORD=0.
I didn't check which of them are the minimum requirement. Anyway, indeed, enabling DDE would be a security risk.
I am trying to hide and unhide series in a chart based on their name using excel vba and I have a error 1004 invalid parameter after the first run of the for cycle.
Sub macroChart3()
'
' macroChart3 Macro test
'
Dim i, n As Integer
For i = 1 To 96 Step 1
If ActiveChart.SeriesCollection(i).Name = "*contracted*" Then
ActiveChart.SeriesCollection(i).IsFiltered = False
Else
ActiveChart.SeriesCollection(i).IsFiltered = True
End If
Next i
End Sub
SeriesCollection.IsFiltered method seemed to toggle this check box:
I couldn't use that. I wanted to record macro and see if any other method is used but the checkbox is gone in 2010:
So it might be not possible to use that anymore. If you are using a different version where this method exists you might have a problem that the series is not listed in in seriesCollection anymore:
Remarks from MSDN
When a user filters out a series, the series IsFiltered property switches to True, and the series is transferred out of its parent SeriesCollection.
See if you can use FullSeriesCollection instead when you change the visibility of series:
ActiveChart.FullSeriesCollection(2).IsFiltered = True
If that doesn't work you might add and remove ranges instead of hiding them.
UPDATE:
Run your macro in step mode (F8) so you have full visibility of the execution steps. Add your evaluated expressions (ones that are used within IFs) to see their result and you will find out if they are incorrect or are evaluated as FALSE and try to figure out why.
And don't forget to up vote the answer if you find it helpful.
thanks for the quick reply, the error is fixed, but still not all the series are processed by the if clauses in the for cycle, for example this statement:
Else
ActiveChart.SeriesCollection(i).IsFiltered = True
End If
Isn't executed and I don't understand why.
The code below has worked until my most recent update to it in. It still does work, but for some reason, it errors when opening it on a new PC if you have to click Enabling Editing. If you Enable Editing, end the routine, and close the spreadsheet, it works from there. I am just trying to understand what might be causing the hiccup on the initial open after Enabling Editing.
The code (please note that "Mnger_Tags" is a named group defined in the spreadsheet):
Dim Mnger As Variant, MngerCheck As String
Application.DisplayAlerts = False
'Determine User/Manager
Mnger = Application.Transpose(Range("Mnger_Tags").Value)
MngerCheck = LCase(Environ("UserName"))
If IsInArray(MngerCheck, Mnger) Then
frmMngerCheck.Show
MngerCheck = frmMngerCheck.MngerCheck
Unload frmMngerCheck
End If
The Error:
Takes place on line "Mnger = Application.Transpose(Range("Mnger_Tags").Value)"
Run-time error '1004':
Method 'Range' of object '_Global' failed
The goal:
The first line of code is meant to take whatever names are listed in that named range (Mnger_Tags) and create the array Mnger.
The code will then check if any value in the array Mnger match the UserName (MngerCheck).
I hope this is clear enough. This is my first post. Thank you all in advance.
Using Excel 07
Below is the code I currently have working. However when I assign it to a code the section where it clear contents does not run but everything else does. If I just F8 through it clears the contents no problem at all. I am not sure why this is and was hoping you could help.
Sub Save_Session()
Call UnProtectAll
If Worksheets("Drawing").Range("A2").Value = Worksheets("Drawing").Range("I2").Value Then
i = (Worksheets("Drawing").Range("B2").Value * 25) - 24
Worksheets("Drawing").UsedRange.Copy Destination:=Worksheets("Sessions").Range("A" & i)
Worksheets("Drawing").Range("B2").Value = Worksheets("Drawing").Range("B2").Value + 1
With Sheets("Drawing")
Range("A2").ClearContents
Range("C2:C20").ClearContents
Range("E2:H20").ClearContents
End With
Else
MsgBox "You do not have all the winners yet!!!"
End If
Sheets("Drawing").Select
Call ProtectAll
End Sub
It's probably working when you step through coincidentally because you happen to be on the sheet "Drawing" when running the macro.
To access properties or parameters of an object, you need to use the "." Since you are already declaring what you are trying to access with the WITH statement.
Here is an article from MSDN explaining how the WITH...End statement works In VBA.
With Sheets("Drawing")
.Range("A2").ClearContents
.Range("C2:C20").ClearContents
.Range("E2:H20").ClearContents
End With