03-20-2023 04:13 AM
Hello,
I am using DPO7254C(Tektronix) and creating the code in VBA to make automatic system.
But there's runtime error like below captured and I don't know why it occurred.
Please let me know what is problem in my code or what I should check.
Below code is to get the caputured screen from oscilloscope and error is on line : [imageBytes = osc.ReadIEEEBlock(BinaryType_UI1, True)]
-------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
Public OSC_ioMgr As New VISAComLib.ResourceManager
Public osc As New VISAComLib.FormattedIO488
Public OSC_GPIO As String
Public imageBytes() As Byte
Sub CaptureScreen()
' Connect to the oscilloscope
Set osc.IO = OSC_ioMgr.Open("GPIB0::15::INSTR")
osc.IO.Timeout = 10000
' Set up the oscilloscope for screen capture
osc.WriteString "HARDCOPY:FORMAT BMP"
osc.WriteString "HARDCOPY:Port FILE"
osc.WriteString "HARDCOPY:PALETTE INKSAVER"
osc.WriteString "HARDCOPY:FILENAME ""Screen shot"""
osc.WriteString "HARDCOPY START"
Sleep 5000 ' Wait for 2 seconds
imageBytes = osc.ReadIEEEBlock(BinaryType_UI1, True)
Sleep 2000 ' Wait for 2 seconds
'Save image to a temporary file
fileNumber = FreeFile
'Open "D:\temp.jpg" For Binary Lock Read Write As #fileNumber
Open "D:\temp.jpg" For Binary Lock Read Write As #fileNumber
Put #fileNumber, , imageBytes
Close #fileNumber
'Load the image back into Excel
Dim picture As Shape
Set picture = Sheets("Sheet1").Shapes.AddPicture("D:\temp.jpg", msoFalse, msoTrue, Sheets("Sheet1").Cells("A1").Left, Sheets("Sheet1").Cells("A1").Top, 1024 * 0.5, 768 * 0.5)
End Sub
03-21-2023 05:56 AM
Hi MinsuPark,
As suggested by NI, could you please try to upgrade this Software that you are using. If it won't work, then try to uninstall and reinstall the driver.
Also, try looking this article as well, (this is a solution for LabVIEW) but you may find appropriate answer from this article.
However, if none of this will solve the issue, I suggest contact Tektronix's support, they may have solution in this case.
Regards)
________
Best way to thank is to give Kudos / Mark as a solution.