|
-
May 3rd, 2004, 11:33 AM
#1
Thread Starter
Fanatic Member
explain this code?
can some one please help me by explaining this code to me? i understand some of it, i just need to know what it does, line by line if possible. thanx for any help
VB Code:
Dim objWord As New Word.Application
objWord.Documents.Add
ActiveDocument.ToggleFormsDesign
objWord.Selection.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
ActiveDocument.ToggleFormsDesign
objWord.Visible = True
-
May 3rd, 2004, 11:47 AM
#2
Lively Member
Re: explain this code?
1: Create a connection to Word
2: Add a new document
3: Add a checkbox to the current doc
4: Go back to forms design mode
5: Make it visible
Nick
-
May 3rd, 2004, 12:02 PM
#3
Thread Starter
Fanatic Member
ok thanx alot.
VB Code:
ActiveDocument.ToggleFormsDesign
objWord.Selection.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
is this all one line?
also the
VB Code:
ClassType:="Forms.CheckBox.1"
could one use this for check boxes that are in a VB6 app, just by changing the name?
-
May 4th, 2004, 01:40 AM
#4
Hyperactive Member
Are you sure that's Visual Basic codes?
I mean it looked that way at a quick glance...but it was this that threw me off to thinking otherwise....
ClassType:="Forms.CheckBox.1"
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
May 4th, 2004, 10:52 AM
#5
Thread Starter
Fanatic Member
yeah i think that it is VB code, someone gave me this off of this forum, i was asking if there was a way to put check boxes into MSWord from a VB app.
-
May 4th, 2004, 11:04 AM
#6
Fanatic Member
It absolutely is VB code....remember that VB is fully supported by COM, and as such, you are able to access a wide variety of components. In the example provided in this thread, the component accessed is an object of type Word.Application (application object)....this is what OLE Automation is all about....the ability to create instances of objects external to your application....this sort of began when companies like Microsoft and Lotus looked for ways to allow users to embed spreadsheets in their word documents, and other operations like that. But from the programming point of view, this also means that we can access these components and do stuff with them according to our needs (like add checkboxes to a word document).
Dubya, someone at some point in this forum made an excellent suggestion: when you record a macro in Word, and then save the macro, go back and open the dialog to run it. But do not run it, instead, click on 'Edit'. The VB editor will open and you will see the code that was generated. This code is supported by the objects that word supports (these objects have properties and methods)....so if you instantiate the same type of objects in VB, you will have the same properties and methods available to you. Hope that is not too confusing. cheers
"Knowledge is gained when different people look at the same information in different ways"
- Louis Pasteur
-
May 4th, 2004, 11:16 AM
#7
Thread Starter
Fanatic Member
that a good idea about the macro. do u know it is possible to put the check marks at a specific place in the Word document, such as a bookmark?
-
May 4th, 2004, 02:26 PM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|