DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can you call a .set from VBA?

 
Post new topic   Reply to topic    DPlot Forum Index -> Excel
View previous topic :: View next topic  
Author Message
Phillip Mathis



Joined: 10 Dec 2009
Posts: 21

PostPosted: Sun Apr 25, 2010 10:43 am    Post subject: Can you call a .set from VBA? Reply with quote

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
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sun Apr 25, 2010 10:54 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Phillip Mathis



Joined: 10 Dec 2009
Posts: 21

PostPosted: Wed Apr 28, 2010 8:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Wed Apr 28, 2010 10:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Phillip Mathis



Joined: 10 Dec 2009
Posts: 21

PostPosted: Thu Apr 29, 2010 8:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Thu Apr 29, 2010 8:32 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Excel All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group