Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
-
yhadad
- Posts: 33
- Joined: Tue 30. Oct 2018, 18:13
Post
by yhadad » Tue 13. Nov 2018, 17:13
Hello,
I have an automated plotter that records data once I start a macro to run a test. Once the macro completes the loop, a Save As popup window will appear so that the user can give the data file a name before saving it as shown in the code below.
Code: Select all
Dim PlotDoc, plotter
Set PlotDoc = Documents.Open("Speed.plt")
If Not PlotDoc Is Nothing Then
Set plotter = PlotDoc.ActiveWindow.Object
plotter.ClearAll
plotter.Start
End If
////(My Loop Code)////
Plotter.Stop
PlotDoc.IsActive = True
ExecuteCommand "FilesSaveAs"
Now I need to program it to save to a specific file directory for example if the test passes, then it will have a SaveAs popup that will automatically lead to the file directory: C:\PASS and if the test will fail then a SaveAs popup will appear and automatically lead to file directory: C:\FAIL.
Is there a way of achieving that?
Thanks in advance
Kind Regards,
Yousif
-
M.Gerber
- Design & Documentation

- Posts: 68
- Joined: Mon 13. Sep 2010, 16:34
Post
by M.Gerber » Wed 14. Nov 2018, 09:28
Hello Yousif,
Why not using the Save Method of the Document object? There you can specify a file name and a path. According to your if clause you could use the different paths and file names. Maybe in that case it wouldn't even be necessary to prompt the user with Save As anymore.
The path to the help, I've mentioned in the
other thread, gives you the needed information about the Document object.
Kind regards
Mark
-
yhadad
- Posts: 33
- Joined: Tue 30. Oct 2018, 18:13
Post
by yhadad » Wed 14. Nov 2018, 18:34
Hi Mark,
The reason why I want a popup SaveAs with automated file directory path to a "pass" or "fail" folder is because I will have a technician at the plant that will test the e-axle and then during the popup, he will then use a QR scanner to scan the axle which will input the serial number of the axle before saving it. Thank you.
Regards,
Yousif
-
M.Gerber
- Design & Documentation

- Posts: 68
- Joined: Mon 13. Sep 2010, 16:34
Post
by M.Gerber » Thu 15. Nov 2018, 12:33
A possiblity to give a new name or just a new path as parameter to the Save As dialog does not exist.
Maybe you could go another way:
- Use the general InputBox function of VBscript to get the scanned serial number.
- Assemble the full path and name of the file to be saved in the script.
- Use the Save method of the Document object (i.e. PlotDoc.Save).
Hope this approach helps.
Mark
P.S.: The PCAN-Explorer Help (F1) also contains the full scripting reference by Microsoft (lowest main entry in the help's table of contents). For example, you will find the explenation for the InputBox function there.
-
yhadad
- Posts: 33
- Joined: Tue 30. Oct 2018, 18:13
Post
by yhadad » Thu 15. Nov 2018, 21:36
Thank you Mark,
I took your recommendation and made my code to work

Here it is below incase someone else needs help to use my code as an example.
Code: Select all
Dim PlotDoc, plotter, Input, fpath
Set PlotDoc = Documents.Open("Speed.plt")
If Not PlotDoc Is Nothing Then
Set plotter = PlotDoc.ActiveWindow.Object
plotter.ClearAll
plotter.Start
End If
////(My Loop Code)////
Plotter.Stop
PlotDoc.IsActive = True
Input = InputBox("Enter Serial Number")
Input = Input & ".plt"
fpath = "C:\PASS\"
PlotDoc.Save fpath & Input
MsgBox (You entered: " & Input)