Hello everyone, here I have made a piece of code integrated into my macro to insert a jpg image in a solidworks plan. The problem is that I select the plan that is already open with opendoc6 but it doesn't work. When I have the plan open it works but if it's not on the main window it doesn't work anymore.
I specify that at this point in the macro the plan will already be open, but the focus is on a .part, the plan is open but not selected.
Here is the function that should insert the barcode:
Function codebarreDRAW(FCB As String, namePL As String, chemin As String)
Dim myModelView As Object
Dim swModel As ModelDoc2
Dim swApp As SldWorks.SldWorks
Dim swLoadErrors As Long
Dim swLoadWarnings As Long
Dim Fplan As String
Fplan = namePL & ".SLDDRW"
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set myModelView = Part.ActiveView
Set swModel = swApp.OpenDoc6(Fplan, swDocDRAWING, swOpenDocOptions_Silent, "", swLoadErrors, swLoadWarnings)
myModelView.FrameState = swWindowState_e.swWindowMaximized
Dim SkPicture As Object
Set SkPicture = Part.SketchManager.InsertSketchPicture(FCB)
SkPicture.SetSize 130 / 1000, 20 / 1000, True
SkPicture.SetOrigin 110 / 1000, 35 / 1000
End Function
I have an error on the Skpicture.setsize line
The worst part is that the InsertSketchPicture line doesn't crash but the image isn't imported.
If you have any ideas, I'm all for it.
Thank you!