![]() |
#1
|
|||
|
|||
![]()
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 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 Last edited by FaneDuru; 17-12-2012 at 02:35. |
#2
|
|||
|
|||
![]()
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 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 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 08:38. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
RunMacro in the ActiveDocument | pafi | Macros/Add-ons | 1 | 25-01-2010 09:45 |
Using ActiveDocument.SaveAs (c#) | dlpfis | CorelDRAW/Corel DESIGNER VBA | 2 | 28-07-2009 08:39 |
Template files | rbentley | General | 1 | 20-08-2008 13:45 |
Help with ActiveDocument.PublishToPDF | pbisson | Corel Photo-Paint VBA | 5 | 03-01-2007 20:37 |
Help with ActiveDocument.PublishToPDF | pbisson | Macros/Add-ons | 0 | 15-12-2006 16:27 |