Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5625

Runtime Error for 'Readieeeblock'

$
0
0

Hello,

 

I am using DPO7254C and I am making a VBA code to create automatic system.

But I don't know how to create the code to get the screen captured from oscilloscope by VBA.

I just want to get the screen and paste to specific cell in excel that I want.

 

My code is below, and there's error 'VI_ERROR_TME' on 'imageBytes = osc.ReadIEEEBlock(BinaryType_UI1, True)' line.

 

What should I do?

Please Somebody Helps Me!!!


--------------------------------------------------------------------------------------------------------------------------------------------------------
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")
    
    ' 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 ""FILE_INKSAVER"""
    osc.WriteString "HARDCOPY START"
    
    Sleep 2000 ' Wait for 2 seconds
    
    imageBytes = osc.ReadIEEEBlock(BinaryType_UI1, True)
                
    '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


Viewing all articles
Browse latest Browse all 5625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>