Solved

VB AddIn, Code to HTML

Posted on 1998-06-30
3
146 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…

747 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

9 Experts available now in Live!

Get 1:1 Help Now