I use the objSNMP.get method in Excel VBA without any problems.
I'd like to use the objSNMP.set method, but unfortunately it's not that easy. According to the website, it should work similarly to get, with the difference that there is one more parameter: the value to be sent.
If I try the official way:
objSNMP.Set ("43.18.1.1.2", OIDValue)
Image1
I get the message "Compile error: Syntax error".
I found another solution that works conditionally. Namely as follows (it can be seen commented out in the picture):
randomVarName = objSNMP.Set("OID", Value)
For example:
temp = objSNMP.Set(".1.3.6.1.4.1.9.9.68.1.2.2.1.2." & PortNum, 21)
In this case, the code runs without error. This is interesting because I haven't found any official information about this anywhere. Somewhere deep in the recesses of the internet, I only found this possible solution some time ago.
If, on the other hand, I do not enter the value directly, but write the name of a variable there (e.g. VLANNum),
temp = objSNMP.Set(".1.3.6.1.4.1.9.9.68.1.2.2.1.2." & PortNum, VLANNum)
I receive an error message. Image2
It doesn't matter if the type of the variable is not declared, string or integer. I also tried several different cell types in Excel, but nothing changed.
The error message is:
Run-time error '-2147467259 (80004005)':
The requested SNMP operation attempted to modify a variable, but
either a syntax or value error occurred.
Based on the above, I cannot insert the value read from the excel table at the end of the "objSNMP.Set" method in such a way that it can send the value. I could only solve the task if I create 4094 different "objSNMP.Set" lines and select what is necessary from among them. Not very efficient.
I have the solution. The value transferred with the variable works in the following form:
objSNMP.Set ".1.3.6.1.2.1.2.2.1.7.9", CInt(x)
Where x is the variable.
Related
I was searching for solution one by another and still have some problems, i am open to change even a whole schema, but i have time till weekend. If you have new solution show me, if i did something wrong please tell me.
This is where it happens
Also earlier i had problem with just initializing variable and puting there value from excel, but now i guess i am on right way. Earlier program told me that i am setting string to my int variable.
Yep, so i did that but still i receive:
InvalidTemplate. Unable to process template language expressions in
action 'var_name' inputs at line '0' and column '0': 'The template
language function 'int' was invoked with a parameter that is not
valid. The value cannot be converted to the target type.'.
I don't know what it meens and what to do, what i know is that i can still see and show what i got from my excel, also in excel file every cell i get is set to be Integer.
Can someone help me? I can show You more if its necessary.
I changed type of cells to intiger in my excel, also i made this function, and still none. Help, i do not have time and i worked on it for too long.
My Excel 2016 VBA code has rare occasions of fatal errors (e.g. loss of variable or reference values).
It sends mail/text then.
I'm looking for a way to state in which module and code line the problem occurred.
Is there a VBA command that can read the module name and the line number?
...without hard-coding the module and function/sub name.
You can use Erl as long as you have added line numbers to the code.
My idea of best case scenario for emailing fatal errors:
Save all the user's input in a class variable. In case of error, mail the information to yourself plus the type of the error.
This should be enough to replicate and fix.
Concerning a way to get the module name without hardcoding - there is no such way. But using a hardcoded variable for the name is not that difficult - http://www.cpearson.com/excel/InsertProcedureNames.aspx
I am using evaluate function in lotusscript to get a value of certain expression.
The formula is working fine when kept in the column of a view, but as soon as it is passed in evaluate, it is throwing error as "Error in evaluate macro", might be I am using wrong suntax.
Set Eval= Evaluate({#Text(#If(#Member(#Subset(txtRejectedApprovers;-1);txtApprover1:txtApprover2:txtApprover3:txtApprover4)-#Member(#Name([CN];txtApprovedApprovers[n]);txtApprover1:txtApprover2:txtApprover3:txtApprover4)>0;"1";"0")))},foundDoc)
txtApprover1 and other fields are coming from foundDoc document.
First thing. You shouldn't use such complex evaluate statement because if there are errors or unexpected results its very difficult to find the reason.
I think your error is one bracket to much at the end of your statement. Here is the code which doesn't return the error:
Set Eval= Evaluate({#Text(#If(#Member(#Subset(txtRejectedApprovers;-1);txtApprover1:txtApprover2:txtApprover3:txtApprover4)-#Member(#Name([CN];txtApprovedApprovers[n]);txtApprover1:txtApprover2:txtApprover3:txtApprover4)>0;"1";"0"))},foundDoc)
I'm creating a macro that opens a file that everyone has on their computer and in order to do so must know the person's username / work ID.
To get the person's work ID I've tried using the following:
sso = IIf(InStr(Application.OperatingSystem, "Windows") = 1, Environ("UserName"), _
'MacScript("(user name as string)"))
Running this on windows returns an error because of the Macscript (I think) and I'd assume the same would happen vice versa, even though the error part of the IIF is never actually accessed I'm guessing seeing as the whole line is executed this is why there is a problem, thus On Error Resume Next would not really help here.
I know this can be easily overcome by just using an if and else statement but I just want to know if I'm right / why this problem occurs and if there are any other more sophisticated ways of achieving what I want.
Thanks
The IIF function evaluates both the true and false parts, or rather it attempts to do so. There is no short-circuit. Your assumption about why it's failing (and also that you can't use an OERN) is correct. You may take a look at conditional compilation logic, if certain parts of your code will not compile on Windows (or Mac, respectively).
http://msdn.microsoft.com/en-us/library/aa240847(v=vs.60).aspx
I am writing some Macros in Excel and everything was going very well.
At the moment, everything is still sort-of working, but I've encountered a strange problem and I can't find any threads about it.
When the program encounters a code error, such as type mismatch or wrong references (examples below), it does not break the code at the culprit line, but just aborts the entire macro and ends it peacefully with no messages or anything.
It's like I accidentally changed a setting or something that is now causing the debugger to not bug me with debug messages.
Please help! I would like my error messages and "just in time" breaks back!
Dim Margin As Double
If COS <> 0 Then
Margin = Round((SALES - COS) / COS * 100, 2)
Else
Margin = "???"
End If
or like a wrong reference:
Dim that_cell as string
that_cell = "5"
Range(that_cell).Select
Thanks,
Pieka
I've just come across this same issue over the past few days. I've spent copious amounts of time extending Access with VBA and never had an issue quite like this. However, I am aware of the Error trapping options and when to use each option. SO, to my chagrin, to fix this error I had to do the unintuitive opposite of what mehow suggested. I actually changed the Error Trapping option to 'Break on All Errors.' All of sudden, I get the debugging options I'm used to getting.
Now, obviously, once you take a piece of code into production, you'll need to choose 'Break on Unhandled Errors' (and pray you've trapped and planned for every concievalbe error.....).
I've just had a similar problem that was caused by me trying to assign a default value of 0 to an optional range object:
Function test(rng1 as Range, Optional rng2 = 0)
test = "Never gets to this line"
End Function
The function returns a #VALUE error without letting you enter debug mode to find out that it is the function declaration line causing the error.
I know it's a rookie error to try and assign a value to a range object, but if anyone else is struggling to enter debug mode, it might be because you are incorrectly assigning values to objects in your parameter list.