Can you call a .set from VBA?

VBA and general Excel Q&A and examples
Post Reply
Phillip Mathis
Posts: 21
Joined: Thu Dec 10, 2009 10:55 pm

Can you call a .set from VBA?

Post by Phillip Mathis »

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
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Code: Select all

    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
Phillip Mathis
Posts: 21
Joined: Thu Dec 10, 2009 10:55 pm

Post by Phillip Mathis »

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
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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
Phillip Mathis
Posts: 21
Joined: Thu Dec 10, 2009 10:55 pm

Post by Phillip Mathis »

Changing from Private to Public worked. Thanks! Can you explain why the double quotes are necessary in the arguement for GetPreferences? Newbie question.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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
Post Reply