I am writing an HTA to automate some processes in SolidWorks, namely exporting various user-selectable views to PNG and allowing the user to select where these images are being saved. I am writing the script part in VBScript because that is most similar to the Visual Basic API documentation that I have found, and I am not using the built-in macro feature because I wanted a GUI and more user-interaction/configuration. Note: this is my first experience with VBScript so it could just be a simple knowledge error.
My issue relates to getting (and possibly saving) a scene. I have found the ISwScene.GetP2SFileName (https://help.solidworks.com/2021/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISwScene~GetP2SFileName.html , yes I know this is given in Visual Basic not VBScript) method which I thought would solve my current issue, but when used I am getting the type mismatch error. Having looked into the other methods that I am using, a stark difference in declaration is evident. The other methods I am using (GetActiveConfiguration, GetScene, GetPathName, etc.) all have the form: Function <name.>() As <dataType.>
This differs from GetP2SFileName which has the form: Sub <name.> ( _ ByRef Val As <dataType.> _ )
Everything else has been functional to this point, so this difference seems to be the root of the issue.
I have tried various ways of declaring my variable, utilizing the Call tag before hand, with and without parenthesis around the variable; but every variation has either led to Type Mismatch, Expected End of Statement, or Object does not support this method. I read through this other question (ByRef and ByVal in VBScript) and the answers to see if it was applicable but nothing described there seemed to work.
This is the relevant code snippet:
<script language="VBScript">
Dim swApp
Dim Part
Dim SceneStore
Dim SceneFile
Dim ConfigStore
...
Sub Window_OnLoad
...
' Solidworks Setup and Grabbing Important Data
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
' above is known working, below is new additions for preserving scene through process
Set ConfigStore = Part.GetActiveConfiguration
Set SceneStore = ConfigStore.GetScene
' SceneFile = ""
SceneStore.GetP2SFileName SceneFile
...
End Sub
...
</script>
Any suggestions would be much appreciated. If you know how to save a scene to a specific location in VBA that would also suffice because I could save the current scene in the SolidWorks macro before creating the shell application and launching the HTA.
Thank you