View previous topic :: View next topic |
Author |
Message |
Phillip Mathis
Joined: 10 Dec 2009 Posts: 21
|
Posted: Sun Apr 25, 2010 10:43 am Post subject: Can you call a .set from VBA? |
|
|
David,
I'm new to VBA programming and just learned how to call the xyyy sub procedure. We just finished testing and have 1000+ csv files that have to be plotted. It would be helpful if the process could be further automated by calling the .set function within Dplot. This may not be possible since the .set file does not reside within the dplot library, but any recommendations would be appreciated.
Thanks,
Phil Mathis |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2311 Location: Vicksburg, Mississippi
|
Posted: Sun Apr 25, 2010 10:54 am Post subject: |
|
|
Code: |
Dim doc As Long
Dim ret As Long
.
.
Call XYXY
doc = DPlotGetActiveDocument()
If doc > 0 Then
ret = DPlot_Command(doc, "[GetPreferences(""filename.set"")]")
End If
|
But if you're always using the same settings file and can remember to leave the first plot open, you might find it more convenient to check "Use settings for current plot" on the Add-In Options command. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
Phillip Mathis
Joined: 10 Dec 2009 Posts: 21
|
Posted: Wed Apr 28, 2010 8:38 pm Post subject: |
|
|
David, thanks for the help. The code errors out with doc =DplotGetActiveDocument. I'll look through and see if I can't debug and find where i'm making an error. Thanks again,
Phil |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2311 Location: Vicksburg, Mississippi
|
Posted: Wed Apr 28, 2010 10:50 pm Post subject: |
|
|
My best guess is you're using an older version of the Add-In, in which DPlotGetActiveDocument is marked "Private" - that is, it is inaccessible from other modules. To change it to "Public" open VBA and click on the + sign next to "dplotlib (dplotlib.xla)" in the left pane. (If you are prompted for a password, use "dplot" w/o the quotes. Then click next to Modules, and double-click on DPlotData. Search for DPlotGetActiveDocument and change
Private Function DPlotGetActiveDocument() As Long
to
Public Function DPlotGetActiveDocument() As Long _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
Phillip Mathis
Joined: 10 Dec 2009 Posts: 21
|
Posted: Thu Apr 29, 2010 8:25 pm Post subject: |
|
|
Changing from Private to Public worked. Thanks! Can you explain why the double quotes are necessary in the arguement for GetPreferences? Newbie question. |
|
Back to top |
|
|
DPlotAdmin Site Admin
Joined: 24 Jun 2003 Posts: 2311 Location: Vicksburg, Mississippi
|
Posted: Thu Apr 29, 2010 8:32 pm Post subject: |
|
|
Yes, and the same applies to any character string arguments to DPlot_Command commands. The entire command is a character string and has another character string embedded. VBA would see
DPlot_Command(doc, "[GetPreferences("filename.set")]")
as
DPlot_Command(doc, "[GetPreferences("
followed by nonsense and report a syntax error. The doubled quotes are the same as (but much easier than):
DPlot_Command(doc, "[GetPreferences(" & char(34) & "filename.set" & char(34) & ")]") _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
|
|