Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Add Textbox To Ms Word-document Through Code


Hello,

I want to make a report that should be printed in ms word 97. I know there is a possibility to add a textbox to a word-document but i wonder if i could do this through vb-code.

can anyone tell me how the insertion of the textbox can be done?

greetz,




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MS Word 2000: Closing Forms In A Document From Another Document With Code
I have a project, in which I use a global template to manipulate different other templates. In those templates there are Userforms built in to gather information to use in a MailMerge. The problem I'm having is that I want only to hide the forms in the templates themselves, and close them in the global template when the whole application is closed. The trouble is that I can't find a way to access the open forms from the global template. Can anybody help me?

Insert Word Document Into A Textbox
currently i am working on a menu for a text editor. On the menu there is a choice of inserting a word document into a textbox. How can i do something like that? and after the word document has been inserted i would like some functions such as copy, paste, cut, save. Any help for inserting the word document and the functions ? thanx

Find Text In Textbox In Word Document`
I can find text fine when the text is in part of the basic Word Document using the .FIND, .Execute methods of the Word Document Object, but if the text is in a textbox, I can't find it. Is there a way to do this?

How Can I Pass Data From Textbox To Word Document In Vb6?
if somebody has a different code, it's accepted to see.

what if i want to use this code:


Private Sub cmdButtom_Click()

Dim WordObj As Word.Application
Set WordObj = CreateObject("Word.Application")
Dim objWord As Word.Document
Set objWord = WordObj.Documents.Open(FileName:=App.Path & "INVOICE.doc")
WordObj.visible = true
With objWord.Bookmarks
.Item("NAME").Range.Text = txtName
.Item("ADDRESS").Range.Text = txtAddress
.Item("CODE").Range.Text = txtCode
.Item("PHONE").Range.Text = txtPhone
.Item("FAX").Range.Text = txtFax
End With
Set objWord = Nothing

End Sub

the error message now is:

"user-defined type not defined"

it doesn't recognize "dim WordObj As Word.Application
so the problem is with "as word.application"

but it recognizes set objword=CreateObject ("Word.Application") , there is no error from the compiler when i use that command.

what should i do so that it recognizes the "dim WordObj As Word.Application" command?
do i need to change something in references or anywhere else?

How Can I Extract Text From A Word Document TextBox
i have been working on word Document files.

each document has same text format.

i m using the code below to extract text from it,




Code:


Dim sFileName As String 'Name of files within the folder will be stored
Dim i As Integer 'This will count the files read***
Dim wrd As Word.Application
Dim wrdCount As Long 'Number of characters within the file
'Get the first file with extension "DOC" ***
sFileName = Dir$("C:Virology*.DOC") '***
Do While sFileName <> "" '***
Set wrd = New Word.Application 'Create obj of word application
wrd.Visible = False
wrd.Documents.Open "C:Virology" & sFileName
wrdCount = wrd.Documents(1).Characters.Count
Text1.Text = Text1.Text & vbCrLf & i & wrd.Documents(1).Range(0, wrdCount).Text
wrd.Documents(1).Close
Set wrd = Nothing
sFileName = Dir$ '***
i = i + 1
Loop







This works good for all the characters in the document but the problem rises when word textbox appears in the document.

Insert Textbox Into Word Document...(Resolved)
Hello there..

I would like to insert a textbox with some text in it into a microsoft wrod deocument and places it in the right hand top corner of the document.....any suggestions


Something like this..?

wrdApp.Selection.Type = wdSelectionNormal
wrdApp.Selection.CreateTextbox
wrdApp.Selection.ShapeRange(1).Line.DashStyle = msoLineDashDot

Thanks

wrdSelection.TypeText "This is some text."
wrdDoc.Content.Select
wrdSelection.CreateTextbox

does the trick

How To Copy And Paste From TextBox To Word Document ?
I use this code to copy selected text from my textbox to the clipboard:
Clipboard.Clear
Clipboard.SetText Text1.Text
Any idea how can I change the code to make it copy and paste in one go in my active Word document at the place where the cursor is located?
Perhaps I need to add Microsoft Word as a reference from the Reference Dialog Box.
dim x as word.application
set x = new word.application
Now I do not know what to do next?
Thank you.

Save Word Document As Textbox Text And Date?
How can I save a word document as text from a textbox and todays date automatically and without getting messages then close MS Word.

Let's say textbox1.text has number 1 in it, when I click on a commandbutton1 it closes the document as 1_12-17-03.

I use VBA.

Thank you very much.

How Do I Pass Values From A Textbox To An Array Which Is Placed In A Word Document ?
how to pass values from textboxes of vb into word arrays.
i mean , suppose i have a word with an array in it(the array consists of 3 cols and 6 lines) how can i say to vb "i want you to take the value from textbox1 and paste it to cell (2,5) of that array?

must the array have a name and how do i name it?

VB Code In Word Document
Does anyone know if the following is possible: I'd like to paste or import some VB code into a word document, but i'd like to keep the colors (f.e. bleu for codewords, green for comment).

I wouldn't like waste time changing all the colors manually.
And the code is too large to just take a screendump...

I don't know if this is possible... does anybody of you guys?

Printing A Word Document Through Code
i have opened a saved word document using vb, it then adds certain criteria using bookmarks etc. now i want to print that document thru code. ive tried using the basic .print function but it wont work ...any help?
thanx in advance

The Code To Get Text From Word Document
The code to get text from Word document ...?

Insert Richtext Into A Word Document Using Code
I have a Word Addin, the form contains a rich text box.

I would like the user to be able to edit the box, and then press insert.

The text is then inserted into the word documenting holding its format.

Does anyone know how this works?

Insert Two Tables In Word Document Through Vb Code
Hi,

Can anybody help me in inserting two tables to a single word document through vb code.

One table contains 4 rows and 6 cols

and another table contains 23 rows and 5 columns

Showing Code In Microsoft Word Document
I am doing VB as part of a project at school. I need to present this project using Word Documents. How can I show code snippets in Word so that the font, formatting and colour are the same as it looks in Excel VBA (or the Visual Basic suite editor). This is purely for presentation purposes. I would like something like you have here where you can quote code and it displays almost exactly like it does in the editor. When i just copy and paste code into Word, it doesn't look very good, and just looks like regular text.
Any help would be much appreciated.

Luke

Inserting Bullets In A Word Document Using Vb Code
i have a code that lists files in the folder and its subfolders. but it needs to be bulleted the code works fine , puts proper bullets in the first looping but when it moves to the second folder the indent is gone. heres the code:

listfiles is a function that displays the files in a folder.


VB Code:
Sub listfiles(folder2 As String)        With wrdobj.FileSearch        .LookIn = folder2        .FileType = msoFileTypeAllFiles        .Execute        totalfiles = .FoundFiles.Count        If totalfiles > 0 Then        Dim i As Integer        i = 1                While totalfiles > 0                        wrdobj.Selection.TypeText Text:=Right(.FoundFiles.item(i), Len(.FoundFiles.item(i)) - InStrRev(.FoundFiles.item(i), "")) & vbCrLf            totalfiles = totalfiles - 1            i = i + 1        Wend            wrdobj.Selection.Range.ListFormat.ListOutdent            wrdobj.Selection.Range.ListFormat.RemoveNumbers wdBulletGallery        Else            wrdobj.Selection.Range.ListFormat.RemoveNumbers wdBulletGallery            wrdobj.Selection.Range.ListFormat.ListOutdent                    End If    End With    End Sub  Dim filobj As New FileSystemObject                Dim subfolder As Folder                Dim mainfolder As Folder                Dim nestedfolder As Folder                Set mainfolder = filobj.GetFolder(selectedfolder)                total = total + mainfolder.Files.Count                                                             wrdobj.Selection.TypeText mainfolder.Name & vbCrLf                    If mainfolder.SubFolders.Count > 0 Then                                                For Each subfolder In mainfolder.SubFolders                                                    wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(2)                            wrdobj.Selection.Range.ListFormat.ListIndent                            wrdobj.Selection.TypeText subfolder & vbCrLf                            wrdobj.Selection.Range.ListFormat.RemoveNumbers wdBulletGallery                                                        If subfolder.SubFolders.Count > 0 Then                                For Each nestedfolder In subfolder.SubFolders                                                                        wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(3)                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    wrdobj.Selection.TypeText nestedfolder & vbCrLf                                    wrdobj.Selection.Range.ListFormat.RemoveNumbers wdBulletGallery                                                                        wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(1)                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    listfiles (nestedfolder)                                Next                                    wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(3)                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    listfiles (subfolder)                            Else                                    wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(3)                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    wrdobj.Selection.Range.ListFormat.ListIndent                                    listfiles (subfolder)                            End If                                                   Next                        wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(2)                        wrdobj.Selection.Range.ListFormat.ListIndent                                                  listfiles (mainfolder)                        wrdobj.Selection.Range.ListFormat.RemoveNumbers wdBulletGallery                    Else                        wrdobj.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=wrdobj.ListGalleries(wdBulletGallery).ListTemplates(2)                        listfiles (mainfolder)                    End If                MsgBox "The files in the folder " & """" & folder1 & """" & " and its subfolders have been listed in the Word document " & """" & "Folder Listing - " & folder1 & ".doc" & """" & " in the " & """" & folder1 & """" & " folder."                wrddoc.SaveAs (selectedfolder & "Folder Listing - " & folder1 & ".doc")                wrddoc.Close                Set wrddoc = Nothing                wrdobj.Quit                Set wrdobj = Nothing

How Do I Convert A Microsoft Word Document To Vb Code?
im sorry for probably such a dumb question but i am a member of the ipaqhq forums and there is a section where you can set up this thing called MY PDA to display all the programs you have in your ipaq.

anyway i was up late lastnight creating one with hyperlinks to all of my software using microsoft word, it took me a couple of hours.

only to find out that it wouldn't post correctly because it need to be vb code.

here is what it is supposed to look like.

http://www.ipaqhq.com/forums/vbgarag...=view&id=12136

i dont want all of that to go to waste so is there a way to convert the word document to vb code?

i have done some searching but i cant seem to find anything on this...

much! much! much! appreciation in advance.

Exporting Code Into Word Document For Write Up??
Hi i need to put certain procedures into my project write up. I would like to keep the color formatting that VB uses when i paste the code into my word document.

Does anyone know of a way i can do this, as it is very difficult to distinguish between code and comments otherwise. plus it will look much nicer.

hope u can help

Thanks

Dan

Deleting A Ctrl Code From A Word Document?
Can anyone tell me how to locate and delete a ctrl code in a word document... I think it can be done in only a couple of lines, but how???

How To Create Lock For Word Document Thru Visualbasic 6 Code?
hi Buddies,

my code does the parsing from the XML file and its details are written in a word document.

while the application runs the code starts writting detatils which got from the xml in the word document assume that it take 1 minutes to complete. Meantime the user is now try to open the word document and from the taskbar it gots open. he/she trys to modify or interupt the application while word gets writing.

code that im using
worddoc.Visible = True

when i try to change the property into false then it show an error


My Question :

1) How to set a lock untill or unless word gots over.
2) Can we acheive from this from vb 6 code.
3) can i control the word document thru vb code.

Note: since the VB and Word are two different applications

I need ur valuable suggesions and tips


Regards,
Moulee

Sample Code For Making A Package Simillar To Word Document
hai ,

Being a starter i feel bit difficuilt in building up this package and it would of great if any one can send me the sample code which has the property of similiar to ms word somthing like having File,Edit,Formate and their properties.Hope i will gwt responce.

thank you
have a good day and bye
premi

Urgent : How Do I Merge Cells In A Word Document Table Through VB Code
Hi

   I am working on VB6 where in i want to export the data from VB6 to a word document. I am facing with 2 problems

1. I actually want the text to come first and later the Table, but from my code, i am getting table first and later the text.

2. I want to merge 2nd and 3rd columns in first row and 4th and 5th columns in first row. How do i go about it.

   The table has to contain 5 columns. If i merge it is not accepting the next columns

Quote:
the code is as bellow

Private Sub Command1_Click()
    'Dim objword As Object
    Dim llRow As Long
    Dim llCol As Long
    Dim j As Integer
    
    Dim objword As Word.Application
    comdlgSaveas.Filter = ".doc"
    'Show the save dialog box
    comdlgSaveas.ShowSave
    sFilename = comdlgSaveas.FileName

    If Trim(sFilename) <> "" Then

    Set objword = CreateObject("Word.Application")
    Dim rng As Word.Range
    Dim myrange As Word.Range
With objword
    .Documents.Add
    .ActiveDocument.PageSetup.LeftMargin = 70
    .ActiveDocument.PageSetup.RightMargin = 70
    .ActiveDocument.PageSetup.TopMargin = 30
    
    Dim tbl As Word.Table
    Set rng = .Application.ActiveDocument.Paragraphs.Item(1).Range
    
    With .Application.ActiveDocument.Range
        .InsertBefore "Parent Name" & vbTab & txtParent.Text & vbCrLf
        .InsertBefore ("Location name:" & vbTab & txtLocation.Text & vbCrLf)
        .InsertBefore ("Census Year:" & vbTab & txtYear.Text & vbCrLf)
        .InsertBefore ("Crude Birth Rate :" & vbTab & txtCbr.Text & vbCrLf)
        .InsertBefore ("% Urban Population:" & vbTab & txtUrbanPer.Text & vbCrLf)
    End With
    Set rng = Nothing

    Dim rngs As Word.Range
    Set rngs = .Application.ActiveDocument.Paragraphs(1).Range

    With rngs
         Set tbl = .Application.ActiveDocument.Tables.Add(rngs, 24, 5)
        If .Application.ActiveDocument.Tables.Count >= 1 Then
        With .Application.ActiveDocument.Tables(1)
         .Rows(1).Shading.Texture = wdTexture10Percent
         .Columns(1).PreferredWidth = 50
         .AllowAutoFit = True
        
         .Cell(1, 2).Merge .Cell(1, 3)
         .Borders.Enable = False
         .Cell(1, 3).Merge .Cell(1, 4)
         .Borders.Enable = False
        End With
    End If
        
         For llRow = 1 To vsfgTotal.Rows
           For llCol = 1 To vsfgTotal.Cols
' If llRow = 1 And llCol = 3 Then
' .Application.ActiveDocument.Tables(1).Cell(1, 3).Merge (.Application.ActiveDocument.Tables(1).Cell(1, 2))
' .Application.ActiveDocument.Tables(1).Cell(1, 2).Range.InsertBefore (vsfgTotal.TextMatrix(0, 1))
' Exit For
' Else
' .Application.ActiveDocument.Tables(1).Cell(llRow, llCol).Range.InsertBefore (vsfgTotal.TextMatrix(llRow - 1, llCol - 1))
' End If
           Next
       Next
        
       End With
        .ActiveDocument.SaveAs sFilename
End With

     MsgBox "Profile Saved", vbInformation, Me.Caption
    objword.Documents.Close
    objword.Application.Quit
    Set objword = Nothing
    Set objApp = Nothing

    End If

End Sub

From the code if u can understand i want the Text part i.e., Parent name, location name etc. should come first and later the table but i am getting table first and later the text part


Do help me in this regard

Thanks in advance

bye

Quote:Thanks in advance

Opening Word Document From Excel When The Word Document Is Read Only
I'm trying to open a Word document from Excel and have hit a snag. The file I'm trying to access is Read-only and the code stops when the "This file is read-only..." prompt displays. How do I get past this? Here's the code that I have so far (thanks to some help from this forum):

Code:
Sub OpenAndPrint()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim stPathName As String

stPathName = Range("B4").Hyperlinks(1).Address

If Dir(stPathName) <> "" Then
Set wdApp = New Word.Application
wdApp.Visible = True
wdApp.DisplayAlerts = wdAlertsNone 'Tried to turn off the prompt, but it didn't work.
Set wdDoc = wdApp.Documents.Open(stPathName) 'Code stops here and waits for the user to respond to the prompt.
Set wdDoc = Nothing
Set wdApp = Nothing
Else
MsgBox "The file does not exist!", vbInformation
End If

End Sub

Merging/Importing Word, Excel, Powerpoint And Visio Files Into A Word Document
Does anyone know how to do this or know of a website that has source code that does this? I can't find anything anywhere.

Each Page/Worksheet/Slide goes on a seperate page. Print formatting is retained (landscape/portrait) and if the imported Page/Worksheet/Slide is larger than the page im merging/importing to, it should auto-resize to fit the page.

Thx.

Run Code Inside Document When Loading That Document
How can i run the code from a document when that document gets opened / loaded?

Reading The Word Document From Visual Basic Without Opening The Word Applicaiton
Hi

I need to access the word document from visual basic without opening the word application. I can do this by opening the word application. Is there any other way to read a document from vb.

I need to search for a particular word in the document without opening the word application.

Waiting for your reply,

thanks

Mohan

Accessing Word Document 'header/footer' Via Word Object Library
Hi All

As the title suggests really, I can access everything I need on a Word document opened via the Word Library object but I can't find how I access the headers and footers of a docuemnt

Many Thanks
Steve

Merging Word, Excel, Powerpoint And Visio Files Into A Word Document
Does anyone know how to do this or know of a website that has source code that does this? I can't find anything anywhere.

Thx.

I posted this in VB General but then i saw this forum so I wasn't sure where it belonged and posted in both. Reply to either one.

Error 4605 Calling Word.Document.Save With Word 2002 SP1
I have a test VB6 exe project with a WebBrowser control, called web1 (added via Project, Components, Microsoft Internal Controls). My project also references the Microsoft Word 10.0 Object Library.

As well as the WebBrowser control, my form has a Save button (cmdSave). Here is the complete code:


Code:

Private g_objDocument As Word.Document

Private Sub cmdSave_Click()
g_objDocument.Save
End Sub

Private Sub Form_Load()
Dim strFileName As String
strFileName = App.Path & "WordWrapper.doc"
web1.Navigate strFileName
End Sub

Private Sub web1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Set g_objDocument = pDisp.Document
End Sub


The idea is when I run the exe, it loads a Word document into the WebBrowser control. This document is also assigned to
a global Word.Document object, g_objDocument, when web1 navigates to it. The problem occurs when I try to save the document (in cmdSave_Click). I get the error:

"The Save method or property is not available because this document is in another application."

This error occurs with Word 2002 SP 1 (on Windows XP), but not with Word 2000 SP3.

Please help.

Load Word Document In VB Form And Use Word's Zoom Features - Help
Hi

I've this VB6 application where I can opt to load a word document or scaned 8X11 image of a paper form on the VB form and let user write or draw using a tablet. Since screen doesn't have enough space to show complete form at one time, I need to zoom it down to fit the screen so it get mapped properly with tablet. Once user is done drawing or writing, I need to bring the document or image back to original size and print it or save it.

I don't know where to start. Plese guide me about the best way to accomplish this. Thanks.

Convert Html To Word Docuemtn Using The Word Document Object
i ant in vb6 to open an html page
and convert and save it as word *.doc
how can i do this?
and is it possible to open the html file from the internet with a give url so i will be :
open html document from www..../1.html -> save as 1.doc
thnaks in advance
peleg

Load Word Document On VB Form And Use Word's Zoom Fetrures - Help
Hi

I've this VB6 application where I can opt to load a word document or scaned 8X11 image of a paper form on the VB form and let user write or draw using a tablet. Since screen doesn't have enough space to show complete form at one time, I need to zoom it down to fit the screen so it get mapped properly with tablet. Once user is done drawing or writing, I need to bring the document or image back to original size and print it or save it.

I don't know where to start. Plese guide me about the best way to accomplish this. Thanks.

VB In Access To Find And Format A Word In A Mailmerged Word Document
I use my Access data base to create mail merged letters to our customers. Not only are the names etc stored on the database I also store the content of the letter in memo fields. I have occasions where I want the newly created letter to have some words bold. After having VB code open the main document, mail merge then close the main document I run the following code. It works the first time round, the specified word becomes bold. However after closing the letter and running it a second time the new letter opens but no changes are made and I get an error. "Run Time error '462' : The remote server machine does not exist or is unavailable". This gives me a Debug option. When selecting debug The first row in this code is selected.

With ActiveDocument.Content.Find

    .ClearFormatting
    .Font.Bold = False
    .MatchCase = True
    .Text = "SATURDAY"
    With .Replacement
        .ClearFormatting
        .Font.Bold = True
        .Text = "SATURDAY"
    End With
    .Execute Format:=True, Replace:=wdReplaceAll
End With

If I leave the new letter open and re run it the code opens a second new letter with no errors, however it does not make the changes to the newest document only the first new document it finds. ie If I then close the first one created and rerun it the second document will have the changes made and the third one does not change. The error only occurs once I have closed all new documents and try to open another letter.


Hope someone can help

MSAccess Database DOA

Word Automation - Retaining The Numbering Format In New Word Document
Hi all,

I am using word automation to read a word document. I use word automation to read the word document page by page and paste the contents of each page in a new document.

The problem i am facing is, the word document which is read contains Heading1,Heading 2 etc and these are numbered. When I paste these pages onto a new document the numbering is not retained. (Eg., if my Heading1 number is 2.1 when i paste it in a new document the Heading1 number is shown as 1.1)

VBA: Creating Word, And Sending Data To A Word Document Using Ranges
The following code works fine when it is executed only once in any instance of the VB program.

It is OK provided I do not close Word, and it will create multiple instances of the document into the same instance or word.

Screen.MousePointer = 11
GetWord2
WordApp.Documents.Open ("C:Program FilesWill WizardTemplatesClauseLib.doc")
set MyDoc = Documents.Open(FileName:="C:Program FilesWill WizardTemplatesClauseLib.doc")
set FldRng(1) = MyDoc.Range(Start:=MyDoc.Bookmarks("Name").Range.End, End:=MyDoc.Bookmarks("NameEnd").Start - 1) 'read bookmarks into range object variables
FldRng(1).Text = ClauseHold 'put the stuff into the document
WordApp.ActiveDocument.SaveAS FileName:=("C:Program FilesWill WizardTemplates emp" & Trim(Str(TMPNum)) & ".doc")
WordApp.Application.Activate
WordApp.Visible = true
set WordApp = nothing
set MyDoc = nothing
Screen.MousePointer = 0
Command8.Enabled = true
Exit Sub



If Word is closed, and the code is executed again, an error occurs "the remote server machine does not exist or is not available" The only remedy for this is close and re-start the VB application containing this code.

The GetWord2 et-al Function codes are: (which is stored in a module)

option Explicit
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string) as Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, byval lParam as Long) as Long
public WordApp as Word.Application
public WordWasNotRunning as Boolean ' Flag for final word unload

public Sub DetectWord()
' Procedure detects a running Word and r
' egisters it.
Const WM_USER = 1024
Dim hwnd as Long
' If Word is running this API call retur
' ns its handle.
hwnd = FindWindow("OpusApp", vbNullString)
If hwnd = 0 then ' 0 means Word Not running.
Exit Sub
else
' Word is running so use the SendMessage
' API function to enter it in the Running
' Object Table.
SendMessage hwnd, WM_USER + 18, 0, 0
End If
End Sub
public Sub GetWord2()

' Test to see if there is a copy of Micr
' osoft Word already running.
on error resume next ' Defer error trapping.
' Getobject function called without the
' first argument returns a
' reference to an instance of the applic
' ation. If the application isn't
' running, an error occurs.
set WordApp = GetObject(, "Word.Application")
If Err.Number &lt;&gt; 0 then
WordWasNotRunning = true
else
WordWasNotRunning = false
End If
Err.Clear ' Clear Err object In Case error occurred.
' Check for Microsoft Word. If Microsoft
' Word is running,
' enter it into the Running Object table
' .
DetectWord
If WordWasNotRunning = true then
'set the object variable to start a new
' instance of Word.
set WordApp = new Word.Application
End If
' Show Microsoft Word through its Applic
' ation property. then
' show the actual window containing the
' file using the Windows
' collection of the MyWord object refere
' nce.
WordApp.Visible = true
WordApp.Application.WindowState = wdWindowStateNormal
Screen.MousePointer = vbDefault
End Sub



do I need to close the document? = deactivate something?

I would like a code example on how to fix the above, else, any suggestions, ideas...


Jason.

A Search Of A Word Document And .XLS Document
Hello,
I need to search a word document for time values that look like this 13:43:42. Find them in a spreadsheet document. Once found there are 3 columns of data in the .xls that correspond to the time. This then needs to go into a .txt file. Then need to search the word document again for the next time and do again. When done the final .txt file should have the time and cooresponding data across the page. Who out there can put this together to run in a macro?

Word Document (*.DOC) And WordPad Document (*.DOC) ?
Hi,

I need to identify that a document file (*.DOC) is a Word document or a WordPad document in me program. Because WordPad can not open always a file (*.DOC) which can be openned by WORD.

Thanks

nYU

Word: Counting A Specific String In A Word Document
Hi all,

After visiting the Word FAQ I couldn't find any clue for my query:
I would like to count (in VB) how many times the string "Yesterday"
appears in a word document I am working on.

By using the manual Replace function (replacing "Yesterday" by "Yesterday"),
Word tells you how many replacement it has done and therefore how many
instances of the string "Yesterday" were in the document.

Can anyone point me in the right direction about using VB to find out
how many times "Yesterday" appears in my document, please?

Many thanks
Francois

Can I Insert A Word In The Cursor Position In A Word Document
I use this statement in VBA2000:

ActiveDocument.Content.InsertAfter ("USA")

but it alwasy insert at the end.

How can I insert a word in the cursor position?

Selecting A Particular Word From A Word Document (.doc) Through Visual Basic 6
I am a developer using Visual Basic 6. One of my program accepts some values through text boxes and then creates a Word document. The text boxes are optional, and the created Word document contains only non-empty values along with appropriate labels. I am able to apply styles (bold and underline) to entire paragraphs. But the user wants me to apply bold formatting only to values entered by him and not to the labels which describe those values. Please help me.

Thank You.

Lalit Kumar Barik
India

Open A Document Word From A Template Of Word
Hello, I'm working in Visual Basic 6 and I want open a document word. But this document must be from a template of word (its name is Informe).

I do it with the code
Dim objWord As Word.Application
Dim objDoc As Word.Document

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add("C:Informe.dot")

It's ok but I only see the document, I want to see the menus of word,....
If it isn't possible can you send me the code to print this document?


Thank's and sorry for my poor english

Word Form &gt;&gt; Process &gt;&gt; Word Document
Please be gentle, as this is my first foray into VBA. To make matters worse, I'm not a programmer, just someone who needs to get something done. My guess, based on what I want to do, it that I can do it easiest in VBA, but I am hoping this forum will help flesh out that answer for me.

In a nutshell, I am trying to create a document (possibly a Word form?...) that has a definite format with fields to be filled in (mostly numberic values, checkboxes, or free text). This form will be filled out by our techs at a customer site. They may do this 'live' with Word open, or they may print it out, then fill in the document later from their handwritten copy.

Next, I would like to 'process' their answers by feeding some information directly into an output document (Word hopefully). Now, some fields like name, address, etc... will go straight over and don't require manipulation. Some other data will need to be processed.

For example, if the tech fills in 34, I might want the output document to put 'this text' under a certain heading. If it is >34, then some other text, less, maybe no text. I'd also like to be able to change some graphics based on limits. i.e. if the value is less than this, insert this picture into the output document at a specific location, if not, insert this picture.

So, in general, before I go down the road of learning a language... do the members here think VBA would be a good choice for this? Would I 'read' from the input document in Word Excel, process in Excel and then pump data out to the output docment, etc... I am looking for advice whether this is;

1. fairly straightforward, understanding that I would need to learn some VBA.
2. possible
3. a good choice. i.e. would another language, or a pre-done software make a better choice.

My contraints are that my company has Office 2000 rolled out, WITHOUT Access. We use Lotus Notes and Access is apparently frowned upon. I am an optimist, so I expect it's possible with careful design and help from the experts who've been down these roads before.

Thanks in advance for any help, insight, advice or code.

Regards,
John

Opening A Word Document With Word From Excel
i want to have a part of an excel macro where it opens up a word document in word (so it would have to open the application itself) and then be able to do everything that i can do using the word vb editor. is there some easy way to do this?

Opening An Application Such As Word Document Using Word
how to open a .doc file using a word exe through vb gui.

regards
raghav

Change Word On The Footer Of A Word Document
I like to change the word "Version 1.0" to "Version 2.0" on every page on the footer of a word documents using VB6 with the word document minimised when the program is making the change. Does anyone know how to do this? Thanks.

Word -VBA / Accessing Content Of A Word Document
Group:

Can you access the conent (document.WholeStory or document.Conent) of a Word document without opening the document or triggering the OpenDocument event?

Mark

Deleting Word Document Using Vb For Word 2000
hi

how to delete a word document from the hard disk using vb for word 2000?
i tried using kill function but it shows an error -"permission denied"..pls can sum1 help?

Find A Specific Word From Word Document...
Hi All,

Need help...

i have a word doc. it contains some data.. and bottom of the page it contain the following paragraphs. its single page word doc.
Code:Very truly yours,
sam
Officer

From vb i want to find word, the next line of the 'very truely yours'. like here in this example i have to capture the value 'sam'.

Any idea how to get that..


Thanks
Balakumar

Edited by - pmmbala1976 on 6/2/2004 4:45:19 PM

Deleting Word Document Using Vb For Word 2000
hi

how to delete a word document from the hard disk using vb for word 2000?
i tried using kill function but it shows an error -"permission denied"..pls can sum1 help?

Copyright 2005-08 www.BigResource.com, All rights reserved