OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 16-12-2012, 09:53
FaneDuru FaneDuru is offline
Member
 
Join Date: May 2012
Posts: 35
Exclamation Set the VBProject of ActiveDocument if Template

How can I find the VBProject of the active document in case of template (Untitled-1, 2, 3...).
For a compiled document I can do that using the next code:
Code:
Dim VBEt As VBE, VBPr As vbide.VBProject, ActVBPr As vbide.VBProject
   Dim NameD As String
   Set VBEt = Application.VBE
    For Each VBPr In VBEt.VBProjects
        NameD = Right(VBPr.BuildFileName, Len(VBPr.BuildFileName) - _
                                            InStrRev(VBPr.BuildFileName, "\"))
        NameD = Left(NameD, Len(NameD) - 4)
        If NameD = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4) Then _
                                                   Set ActVBPr = VBPr: Exit For
    Next
    If Not ActVBPr Is Nothing Then Debug.Print ActVBPr.Name
But how can I find in VBE the VBProject of the active Template document?
For each such document BuildFileName returns 'VBAProject.dll'...

I mean I need something like VBA Excel solves in this way:
Code:
 Set VPPr = ActiveWorkbook.VBProject
Thanks in advance!

Last edited by FaneDuru; 17-12-2012 at 03:35.
Reply With Quote
  #2  
Old 09-01-2013, 14:46
FaneDuru FaneDuru is offline
Member
 
Join Date: May 2012
Posts: 35
Default

I can now 'mark' the template VBAProject using the next code in DocumentNew event of ThisMacroStorage (GlobalMacros):
(Of course referencing "Microsoft Visual Basic for Application Extensibility 5.3")
Code:
Private Sub GlobalMacroStorage_DocumentNew(ByVal Doc As Document, ByVal FromTemplate As Boolean, ByVal Template As String, ByVal IncludeGraphics As Boolean)
       Application.VBE.VBProjects(Application.VBE.VBProjects.Count).Name = _
                                                     Replace(ActiveDocument.Name, "-", "_")   
End Sub
Then, VBAProject of ActiveDocument can be set with the next piece of code:
Code:
Dim V As VBProject, VBAProjectOfActDoc As VBProject
 For Each V In Application.VBE.VBProjects
    If V.Name = Replace(ActiveDocument.Name, "-", "_") Then Set VBAProjectOfActDoc = V: Exit For
 Next
But...
Since the document name is present between parenthesis near the VBProject name I suppose that it can be somehow directly obtained. I just do not know how...

Last edited by FaneDuru; 10-01-2013 at 09:38.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
RunMacro in the ActiveDocument pafi Macros/Add-ons 1 25-01-2010 10:45
Using ActiveDocument.SaveAs (c#) dlpfis CorelDRAW/Corel DESIGNER VBA 2 28-07-2009 09:39
Template files rbentley General 1 20-08-2008 14:45
Help with ActiveDocument.PublishToPDF pbisson Corel Photo-Paint VBA 5 03-01-2007 21:37
Help with ActiveDocument.PublishToPDF pbisson Macros/Add-ons 0 15-12-2006 17:27


All times are GMT -5. The time now is 17:00.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com