Solved

VB AddIn, Code to HTML

Posted on 1998-06-30
3
147 Views
Last Modified: 2010-05-03
Greetings,
I have never worked with an add in before, so I will make this as simple as
possible.
Hopefully, you shall have enough knowledge and patience to guide me.

I am looking to build a very simple add in,
One that shall take the current code inside a VB Form and
save it with the following...
<html>
<head>
<title> Name of form </title>
</head>
<body>

<xmp> or <pre>

Code inside the Visual Basic Form

</xmp> or <pre>
</body>
</html>

Please guide me threw this process,
will only award full points if it works.

Thank you,
S. McColgan

0
Comment
Question by:s_mccolgan
  • 2
3 Comments
 
LVL 4

Expert Comment

by:tomook
ID: 1464652
Piece of cake. Here is the module in question. If you would like the entire working project, send you email address.

Option Explicit

Public GlobalInstance As VBIDE.VBE  ' Initialize this in Connect.OnConnection

Sub ShowComponentCode(sComponentName As String, sHTMLText As String)

    Dim myComponent As VBComponent
    Dim myProj As VBProject
    Dim myCodeModule As CodeModule
    Dim myCodePane As CodePane
       
    Set myProj = GlobalInstance.ActiveVBProject
    sHTMLText = ""
   
    On Error Resume Next
    Set myComponent = myProj.VBComponents(sComponentName)
    If Err.Number <> 0 Then
        ' No component of this name.
        Exit Sub
    End If
   
    sHTMLText = "<html>" & vbCrLf & "<head>" & myComponent.Name & vbCrLf
    sHTMLText = sHTMLText & "</head>" & vbCrLf & "<body>" & vbCrLf & "<xmp>" & vbCrLf
   
    Set myCodeModule = myComponent.CodeModule
   
    sHTMLText = sHTMLText & myCodeModule.Lines(1, myCodeModule.CountOfLines) & vbCrLf
   
    sHTMLText = sHTMLText & "</xmp>" & vbCrLf
    sHTMLText = sHTMLText & "</body>" & vbCrLf
    sHTMLText = sHTMLText & "</html>" & vbCrLf
End Sub


0
 

Author Comment

by:s_mccolgan
ID: 1464653
tomook,
here is my email address
s_mccolgan@hotmail.com

if you do send the sample project, please answer this question with
"Check your email"
I will be more than happy to award the rightfull points.

0
 
LVL 4

Accepted Solution

by:
tomook earned 100 total points
ID: 1464654
Check your email
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use closed file on desktop in vba 6 67
Access 2003, my txt file export is running backwards 4 47
How does CurrentUser work? 10 31
vbModal 12 37
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now