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




Filling A Template In Word Using Visual Basic Problem


hi.
i've made a program in visual basic that takes data from an excel file and fills a template in word.
the template in word is a simple 3x5 table. The problem is that if i try to fill in more than 3 rows or 5 columns in that table i get an error!!
Is like i cannot put more rows or columns in the table.why?
I would appreciate an answer
Thank you,
Thodoris




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Unable To Execute Word Template Using Visual Basic
Hi,

I currently have a Word macro which allows a user to create a new Word document with the standard Word New template or from my MyNew template.

I am using Visual Basic to add a menu option to an existing application from which the Visual Basic program will open a new Word application if one is not already open and then executes MyNew template which gives the user the option of creating a new Word document with either the Microsoft standard Word New template or with MyNew template.

The code I am using right now is :

'-------------------------------------------------

AddIns.Add_
FileName:="C:ProjectMyNew.dot", Install:=True

Dim appWD As Word.Application

Err.Clear

On Error GoTo notloaded

Set appWD = GetObject(, "Word.Application")

notloaded:

If Err.Number = 429 Then
Set appWD = CreateObject("Word.Application")
End If


appWD.Visible = True
appWD.Activate

appWD.Documents.Add Template:="C:ProjectMyNew.dot", _ NewTemplate:=False

'----------------------------------------------------------------

I have been looking around on the web and am pretty sure that

appWD.Documents.Add Template:="C:ProjectMyNew.dot", _ NewTemplate:=False

should create a new document by executing the template specified and then adds it to the existing Word application.

My program currently starts a new Word application and then opens the template specified as a Word document.

Is my method of executing the template wrong?

Thanks.

Filling A Word Template From Access
Helloo

I am trying to fill a word document with data from access. Though i understand the mechanics of this I cannot work out how to send multiple pages of data. E.g. I have a template in word

Project Name
Project Officer
Description
etc

which iwant filled with dtaa form access

If there are 15 projects then i want the word reprt to be 15 pages long each page filled with a different project

Any chance this is possible?

manic

Filling Form Fields In WORD Template Via ACCES And VBA
This may be a beginners question but I cannot find the information so please bear with me.

I am using VBA to exchange information contained in ACCESS tables to and from form fields in a WORD document. (Some fields are within table cells.)

I am partly aware of the way word converts CR to CRLF so that text imported from WORD needs CR converting to CRLF before re exporting. This works fine for text NOT in a table cell but results in two box characters for text inside a table cell.

Now the users CAN just edit the fields but it is a bit of a pain how can I maintain the paragraph markers during import and export. I don't really want to use AddParagraph but write the whole field with its embedded paragraph marks.

I cannot find this information after half a days searching can anyone steer me to a solution? I had vaguely thought about escaping the control string some how??

Thanks for any assistance

Visual Basic 'Template'??
How can I make sure that visual basic saves my 'template'? Every time I open the program I have to maximise the child window. Is there any way to make this the default? Its getting very annoying.... And I looked around and I wasn't sure if this topic belonged here or in the General PC forum. I decided here was much more focused on using VB. Thanks.

Using .doc Template In Visual Basic 6.0
Hi all,
i m using .doc file as template for my vb application.in d .doc file i m retrieving some records from the database in a table.
the table statement is as follows

' for table header
oRange11.InsertBefore "#" & vbTab & "Date & Time" & vbTab & "Health Practitioner and Assessment" & vbTab & "Location of Appointment" & vbCr

' for table row
oRange11.InsertBefore i + 1 & vbTab & Trim(arr2(0)) & vbTab & Trim(arr2(1)) & vbTab & Trim(arr2(2)) & vbCr

' this is the table
Set oTable1 = oRange11.ConvertToTable(Separator:=Chr(9), numRows:=1, NumColumns:=4, InitialColumnWidth:=300, DefaultTableBehavior:=wdWord9TableBehavior)

the records are being retrieved with the help of array - arr2 and is splited like arr2(0)

THE PROBLEM IS -
when the document file is generated, the table data doesnt get wrap.
it displays the data in oneline and the rest of the data gets hide due to specified column width.

so can anyone suggest how i can wrap the text i.e the data in the table.

PLEASE HELP ME...........

Please it's urgent.........

-- Yogita

Create A Visual Basic Report Template
I am currently doing a report template
which serial numbers are increasing by day
ex day 1, 1 , 2, 3
day 2, 4, 5, 6
and the user has to key in the headers
the last serial will be stored in an access db.
The output(report template) will be stored in a word document.

I am having problems with the formating part of document
ex header ,footer, page number and how to generate this report template with the click of a button
"generate report"

Word And Visual Basic [ How Can I Get The Save As Window Through Visual Basic? ]
Hi, I made a small program in visual basic that with the use of

Dim oWord as new word.application
Dim oDoc as new word.document

fills a document with some data from the visual basic.
I want when those data are loaded in word the save or save as window to appear.
The command oDoc.saveAs saves the document without even asking for a filename.

What Can I do?

Blocking Template After Exporting From Access 2002 To A Word Template
I am having some difficulty determining the appropriate code for stopping a template from popping up after I close the document to which my Access data has been transferred to. My VB code automatically saves the document, but when I quit Word, my original template pops up. Whatever code I insert into VBE doesn't seem to stop it. I hope someone can help me.... Here's the relevant portion of the code below:

'Creates a Word instance to use for the 8D form. Uses the existing
'Word instance if there is one; otherwise, creates a new instance.
Set objWord = GetObject(, "Word.Application")
If Err.Number = 429 Then
'Word isn't running; creating a Word object.
Set objWord = CreateObject("Word.Application")
Err.Clear
End If

On Error GoTo Command126_ClickError

strDocsPath = "V:QCProblem Cases" & ""
strSaveName = "BWA CAR No. " & Me![Customer Tracking Number] & ".doc"
strSaveNamePath = strDocsPath & strSaveName
strTemplatePath = "V:QCProblem Cases" & ""
strWordTemplate = strTemplatePath & "8Dform.dot"

'Check for existence of template in template folder,
'and exit if not found
strTestFile = Nz(Dir(strWordTemplate))
If strTestFile = "" Then
MsgBox strWordTemplate & " template not found; can't create 8D form"
Exit Sub
End If

Set objDocs = objWord.Documents
objDocs.Add strWordTemplate
.
.( I have removed the section which relates fields between Access and the template...there's nothing that controls opening and closing of the document)
.
.
With objWord
.Visible = True
.Selection.WholeStory
.Selection.Fields.Update
Debug.Print "Going to save as " & strSaveName
.ActiveDocument.SaveAs strSaveName
.Activate
.Selection.EndKey Unit:=wdStory
End With

Command126_ClickExit:
Exit Sub

Command126_ClickError:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume Command126_ClickExit

End Sub

I would appreciate if I receive a reply ASAP (job-related!!)

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

Filling Template With Data From MS Access
Hi all!

Perhaps somebody could help me:

I have MS Access database with some data for webpages (title, keywords, content & etc) and template file (html).

So, for each record of DB table I need to create webpage containing corresponding data.

Is there any way to open that template and replace variables with data from the table using VB script?

How To Paste On A Word Template Without Loosing The Formatting Of The Template?
I'm new on VB please help me!
I have to fill some special word template with informations caming from an access DB.
Here the code I'm using now.

Private Sub SearchAndReplaceOnce(monDocWord As Word.Document, strTagARemplacer As String)

Dim maPlage As Variant
Set maPlage = monDocWord.Content

With maPlage.Find
.ClearFormatting
.Execute FindText:=strTagARemplacer
If .found = True Then maPlage.Paste
End With
End Sub

All this code is working but the method Paste is replacing also the formatting that I have pre-defined on the word template.
How can I do to avoid this problem?
Thanks

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

Word Object To Save Template As A Template.
I use a word object to open a template and resave it to template.
The reason I'm opening the template is that I want to run a macro that fills the template with data from bookmarks.

I use this code:

Code:
Dim objWordApp As Object
Set objWordApp = CreateObject("Word.Application")
objWordApp.Documents.Add Template:=TemplatePath, NewTemplate:=True
objWordApp.ActiveDocument.LoadMe sConn, FunctionId, sFunctionType, SupplierId
objWordApp.ActiveDocument.SaveAs FileName:=WorkPath & FileName
objWordApp.ActiveDocument.Close SaveChanges:=wdSaveChanges

But when opening the new template I get this annoying reference to the old template. The old macros doesn't save in the new template.

When running save as in word on a template the macros are transferred to the new file without referencing to the old macro.

How do you do this in VB?

Visual Basic And Word
I am writing an application that takes values from visual, puts them into a formatted word document and then output it to the printer. Unfortunately I have no idea how to do this. Any information and code examples of how to do this would be a life saver... Thanks in advance

Visual Basic And Word 97
Hello,

I have a question : How do you to access to a word document properties (author, subject,...) without open this document ???


HELP !!!

Visual Basic & Word
i need to add a button in microsoft word using visual basic.when the button is clicked, a window pops up.

Can some one tell mi wats the steps i need to do until the button is created.

thank you very much.

Visual Basic And Word How To?
Hi, I made and saved a template,and now I want to fill it from Visual Basic.I used as a reference the example from the following link.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313193

If you click on the template link you will see instruction on how to use a template.What I don't know is how to make a bookmark of this kind on word.I also want to know if there is another way to fill in a pre-defined template from visual basic.

Thank you very much!
Thodoris

Visual Basic And Word
hello!

i Have just Created A Word Template (*.dot) that works when ever i double click it , it opens a new document and do all the things it should .
now i m trying to open the template from VB and i use ShellExecute function and it doesnt work it just open the template not a new file.

any ideas how to do this ?

10x

Help With Word And Visual Basic
Hi
I am new to Visual Basic and here is the project I must compelte. We currently have a Word document (that we mailmerge a flat file too). This document contains information for new hires. The users have asked that we add a couple of dropdown list boxes to the word document for them to be able to pick which building the oiffer letter is for. So I have a letter.doc document thtat I mailmerge a file to. Is there a way to add a drop down list box to this document (using Vusial Basic or Word) that can be UNIVERSAL to everyone.
How do you embedd a visual basic form nto a word document and how do you run the visual basic code ?

Any help would be greatly appreciated.

Thanks

Visual Basic And Word
Hi,

Im trying to write a component that should handle the printing of labels. What i want to do is to get names and adresses from a database and then put them into a word document that has labels. I managed to use mailinglabels but could only get one name/adress on the paper, all of the labels contained the same name and adress. I only want one adress on one label. Could someone help me with this?

/magnus

Visual Basic With MS Word
How would I display a text that I input in VB that would display a certain text box in Microsoft Word

Note: Let's say in my word document I have a textbox for LastName, FirstName.

Visual Basic && MS Word
Hi, I'm new to VB and programming. At work, I'm trying to create a form in Word that can be emailed to users, which they can then fill out and return the data to an email address via a "SUBMIT" button. I've figured out how to place the ActiveX controls on the paper (text boxes, check boxes, option boxes, a combobox, and a command button) and it looks good, unfortunately it doesn't work well.

Can anyone recommend a code for me to create a drop down list in my Word Document w/o using the User Form space in VB (you know, something like what you may see on a web page). Also, does anyone have a code which will make my SUBMIT button email the form's data to a specific address?

I also want to protect or lock this document so that it stays out of the Design Mode when given to the end users.

Thanks!

Word In Visual Basic
Hi Guys

Somebody please tell me how do I Create and Format a Word file using Visual Basic.

Thanks

Suhaib

Visual Basic In Microsoft Word.
Hi I just started prgramming and I have visual basic 6, the kind that is in the microsoft word toolbar list. I have several problems. First of all I cant click on the toolbox without it going back into word. Second I cant access the new project window. last of all I cant get all of the form layout window to appear. Please help me as soon as possible! Thanks!

MS Word && Visual Basic - Need Ideas
I'm looking for recommendations from those that have done this before and suggestions on the 'right' method to use.

I "think" I want to apply Word VBA macros to a Word document when requested to do so from a Visual Basic (ver-6) or Visual C++ executable. My question to you experts out there is - where should the macros (code & forms) reside and how do I access them?

I created some Word 2000 VBA macros that do what I want (almost). At this time the macros are stored in a MS Word document (Test.doc). I do not want the macros to be in the subject document(s). Many users and documents get delivered to customers. Basically, I am adding a feature to Word that about 20% of the users will use 10% of the time they use MS Word.

So, my thought is to build an application (VB6 or C++) that allows the user to open a Word document, then apply the macro processing. The user needs to interact with the application to indicate what macros to run and maybe pass parameters - one being the filename to apply the processing to.

Because the macros are coded in VBA, should I (Can I) move them to VB6 and have them work on a document opened via a VB6 executable?

Or should I store the VBA macros in a seperate word file that contains only the macros (code & forms) - would this be a Template file? This scenario would have to open the macro files in Word and the users document file. The document files we use are based on a configuration controlled templates. (We have many word template files). I can not add toolbars, menus, etc. to the Word application because of security concerns.

So, what is the recommended way to do this and where do I find out how? I have done some research, but I can't find anything on the Web (maybe I am looking in the wrong places). MS Dev. Network seems to push the .NET stuff, but I don't have access to that.

Thanks for any assistance you can provide.

Word, Access And Visual Basic
Hello everyone.
I am having a ver hard time trying to do the following:
I have 10 databases in access. Two of them are linked to corresponding word documents. So far, so good. But here is when the problem kicks in.. I've done everything in Access and no one else in the office has Access. therefore, I need to have my databases set-up in such a way so that I can save them and use word templates instead. But I don't know how to start. I tried creating an access webpage. But I have two problems:
1) How do I add new records to the databases?
2) How do I transfer this data to a word template or document?

If someone can shed some light, please....

Thanks

Word Xp Problem With Visual Basic
Hi,

I used to open a word document through visual basic using the folowing code

dim oWord as new Word.Application
dim oDoc as new Word.Document

set oDoc=oWord.Documents.Add("pathOfMyTemplate")

that worked fine with Word 2000 but with Word XP I get the following error:
Method "Add" of object "Documents" Failed

Why is that?Do I have to write some other code in order to open a word xp document?

I appreciate an answer
Thodoris

Visual Basic To Word Source
Could anyone give me a good source of information to learn how to send information from vb to word formatted. I have a program that I want to send a report to word but there needs to be a table created that needs to add rows on the fly as needed. I haven't come across too many sources of good hands on info.

thanks

Visual Basic 6.0 Connecting With Word
Greeting VB-er's:

I have a quick question....

I have a VB 6.0 application which is the front end for our IT department's software/application inventory mdb (access). One of the features of this application is that many of our projects, some created here in-house and others by consultants have word documents which describe the design planning, system requirements, etc. I have a command button on my search form which opens the word document which correlates with the Application name.

My question: I have attached the code below which searches the path and opens the word document if it exists. We are currently in the middle of a migration to Office 2000 from 97. So, some computers have Office 97 and others have Office 2000. In my code I have to reference the Office 97 winword exe in order to launch word: I will admit that I don't have much experience in Word-VB integration and this might not be the best way to do it.

Is there a way to check for which version of word is being run on the cpu before returning the Shell function? Or, even better, is there a way to avoid this command string in general? I really want to avoid paths if possible. Is there some sort of method that automatically calls the version of word found on the CPU? Any ideas would be great, because right now a 2000 user would not be able to open the word documents from this application because they no longer have the valid command string.

THE CODE BELOW: (Function and event code).

Private Sub WordCommand_Click()
Dim Retval
Dim file As String
Dim command As String

command = "C:Office97officeWinword.EXE"

file = "\SHAHANVRvol1userHANOVERhelp_deskCurrentApplicationsdocs" & FoundAppName & ".DOC"

If FileExists(file) Then
Retval = Shell(command & " " & file, vbMaximizedFocus)
Else
MsgBox ("No word document found for this application")
Exit Sub
End If
End Sub


Public Function FileExists(sPath As String) As Boolean

On Error Resume Next

FileExists = False '// default

If Right$(sPath, 1) = "" Then sPath = Left$(sPath, Len(sPath) - 1)

If Dir$(sPath) <> "" Then
FileExists = True
End If

If Err.Number <> 0 Then
FileExists = False
End If

End Function

p.s.-I know this is an ideal VBA forum question, but I am using VB 6.0 so there will be some differences between the two

Visual Basic In Word 2000
What I would like to do is bind all the code that pertains to a specific word .doc and be able to send it with the file (email, download, etc). Right now, all of the functions and subs are localized on the computer I create them on. If I email the .doc to somebody, the code is not sent with the .doc. This is a problem for me.

I realize that there is maliscious possibilities in opening a doc that executes VB code, however that is not a concern for me.

Thanks.

PS - I'm running Word 2000.

Edit: Oops, I posted this in the wrong section. Sorry

Opening MS Word From Visual Basic
Hi,
Is it possible to display an output of a VB code in MS Word file without exiting the application?

Visual Basic And Word 2000 How To?
Hi, I made and saved a template,and now I want to fill it from Visual Basic.I used as a reference the example from the following link.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313193

If you click on the template link you will see instruction on how to use a template.What I don't know is how to make a bookmark of this kind on word.I also want to know if there is another way to fill in a pre-defined template from visual basic.

Thank you very much!
Thodoris

Run A Macro In Word Using Visual Basic
how can i run a macro in word using visual basic. if it is possible pls help

MS Word In Visual Basic Inquiry????
Do you need to have MS Office installed on your computer to create MS Word objects in your VB code??

If not, what references, and/or components are needed to do this?

Any sample code will help.

Thanks

Accessing Word From Visual Basic
why do you need to do this, if you need to change parameters then use the property equivelent:
Open WordRecord a new macroOpen the Templates and Addins windowMake any and all changes and click OKOpen the VBA Editor, find the macro, and use the properties it set to change those setttintgs
Other wise try this:

Code:
'copied from another thread and modified, not my code:
'Mathew Gates code
Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Public Declare Function SendMessageLong& Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long)
Declare Function GetMenu Lib "user32" _
(ByVal hwnd As Long) As Long
Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function GetMenuItemID Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long
Private Declare Function GetMenuString Lib "user32" _
Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal _
wIDItem As Long, ByVal lpString As String, ByVal nMaxCount _
As Long, ByVal wFlag As Long) As Long

Public Const WM_COMMAND = &H111

Private Sub Command1_Click()
Dim notepad As Long
notepad = FindWindow("winword", vbNullString)
Dim TheWindow As Long
Dim aMenu As Long
Dim mCount As Long
Dim LookFor As Long
Dim sMenu As Long
Dim sCount As Long
Dim LookSub As Long
Dim sID As Long
Dim sString As String

TheWindow = notepad
aMenu& = GetMenu(TheWindow)
mCount& = GetMenuItemCount(aMenu&)
For LookFor& = 0& To mCount& - 1
sMenu& = GetSubMenu(aMenu&, LookFor&)
sCount& = GetMenuItemCount(sMenu&)
For LookSub& = 0 To sCount& - 1
sID& = GetMenuItemID(sMenu&, LookSub&)
sString$ = String$ (100 , " ")
Call GetMenuString(sMenu&, sID&, sString$, 100&, 1&)
If InStr(LCase(sString$), LCase("Templates and Add-&Ins…")) Then
Call SendMessageLong(TheWindow, WM_COMMAND, sID&, 0&)
Exit Sub
End If
Next LookSub&
Next LookFor&
End Sub

don't know the class of word, you must find that out before above code will work!!!!

Opening Word In Visual Basic
Hi,
How can i open Ms word in Visual Basic for only viewing,preferebaly
in a MDI child window.Pls send me code samples.
rgds& thks

Word Problem With Visual Basic
Hello,

I am experiencing a strange problem with Visual Basic 6 and Word 2002. I
have a piece of code that opens a word document and sets the margins and
makes it 4 columns with a line between each column. Sounds simple enough but
what happens is that when it opens the first word document in the directory
it formats it fine and then saves it to another directory. It then goes on
the open the next document in the directory and do the same thing to it but
it never changes anything in the document. This happens for all the rest of
the documents it processes. It only works on the first document and fails on
the rest everytime. If I restart the program it works on the first one as
well. I was thinking that it may be a problem in my code not initializing
word object right or something to that effect. Could anyone help?

Here is the code:

Private Sub ConvertWordFiles()
Dim myDoc As Word.Document
Dim wApp As Word.Application
Dim fsoLegals As New FileSystemObject
Dim fileLegal As File
Dim Legals

lblStatus.Caption = "Converting Word Documents ..."
DoEvents

On Error Resume Next

Legals = Dir("c:legalarchives*.doc")

Do While Legals <> ""

lblStatus.Caption = "Processing " & Legals & " ..."
DoEvents

Set wApp = New Word.Application
Set myDoc = wApp.Documents.Open("c:legalarchives" & Legals)

myDoc.Activate

myDoc.PageSetup.TopMargin = InchesToPoints(0.21)
myDoc.PageSetup.BottomMargin = InchesToPoints(13.75)
myDoc.PageSetup.RightMargin = InchesToPoints(13.275)
myDoc.PageSetup.LeftMargin = InchesToPoints(0.1)

Selection.WholeStory

With Selection.PageSetup.TextColumns
.SetCount NumColumns:=4
.EvenlySpaced = True
.LineBetween = True
.Width = InchesToPoints(1.08)
.Spacing = InchesToPoints(0.1)
End With

myDoc.SaveAs "c:legalarchives emp" & Legals
myDoc.Close

wApp.Quit
Set myDoc = Nothing

Legals = Dir
Loop

End Sub

Thanks,

Bob Weiss
Systems Programmer Analyst
The Press of Atlantic City Media Group
609-272-7139
email@removed <')"> <javascript:main.compose('new',
email@removed email@removed

"We can't solve problems by using the same kind of thinking we used when we
created them." - Albert Einstein

"Hell, there are no rules here! We're trying to get something accomplished."
- Thomas A. Edison

How To Export Ppt To Word Using Visual Basic???
how to export ppt to word using visual basic??????????????

Visual Basic And Word Wrap
Hi all, its your favorite guy again with another question. How do you Word Wrap on in the Visual Basic 6 Code Editor, if possible at all.

Thanx in advance, Mike

Microsoft Word OLE Visual Basic 6
I am trying to do something that seems very simple in nature, yet overpowering via code!  =)  Your help is very much appreciated!

1.) I need Visual Basic to open an existing Microsoft Word document.  I have no problems with this part.  ;)
2.) I then need Visual Basic to go through the entire loaded document to replace text.  If I have an occurence of <<customer>> I'd like to replace that with a customer name via Visual Basic code.  As of the moment I'm using the words.item object, but it's really slow.  I really need to find out how to use the replace command but have no clue.  I am asking for any help you may offer...  Thanks a lot!

Visual Basic And Microsoft Word
HI guys!

I have a VB application and I have a function there, for working with Microsoft Word.

this is the begin the code:

  Set WordTemplate = CreateObject("WORD.APPLICATION")
  Set WordReport = GetObject(app.Path + "NewDoc.doc")

  With WordReport.Application
    
    .Visible = True
    .Selection.Find.ClearFormatting
    .Selection.Find.Text = "Construction"
    .Selection.Find.Replacement.Text = "-----------------"
    .Selection.Find.Forward = True
    .Selection.Find.Execute

   ........

My problem is, if the user already has a word document openend or, while I'm working in VB with the Word document and the user goes to other editor, the program crashed and say me the error:

**Object variable or with block variable not set**

this error can occurs in any part of the code where I'm using the wordreport object, for example

WordReport.Application.Selection.MoveLeft Unit:=wdCharacter, Count:=1

I was thinking if I need to close all word applications before I start with this, but, I saw, also, if you don't have any Word document opened, this error occurs

any idea??

thanks

Visual Basic And Word Events
Hi,

I am starting the Word application in Visual Basic.
I want my Visual Basic routine to be called when the user closes the
document in Word.

I am expecting that when the user closes test.doc then the routine
myword_close should be run.

But it does not work!

Please tell me how I should proceed.

Thanks in advance for any help.

Phillip
================================================== =====================
Public mydoc As Document
Public myword As Word.Application

Sub start_editor()

' Start word
On Error GoTo wordprob
Set myword = CreateObject("Word.Application")
If myword Is Nothing Then
MsgBox "Could not start word"
Exit Sub
End If
On Error GoTo 0

' Open the document
Set mydoc = myword.Documents.Open("c:TEMPTEST.DOC")
myword.Visible = True

Exit Sub

wordprob:
MsgBox "Could not start Word " & Err.Description
Exit Sub
End Sub

'
' --- Event handler for Close
'
Sub myword_Close()
MsgBox "Close called"
End Sub

Word Perfect Using Visual Basic
Hi,

   I am developing an application in VB and Word Perfect. I was stuck up at a point of replacing the bookmark with the text from another document. Here in detail of what i need. I have a document in word perfect in which i have some bookmarks in the document. Now i have to read the bookmarks and place the exact data in the book marks. during the process i need to insert a file for certain book marks like signature, letter Head e.t.c.,

Can any one help me by giving me a solution......

Thanks,
Prakash

Word XP And Visual Basic Problem
Hi, I used to open a word 2000 document with the following code

dim oWord as new word.application
dim oDoc as new word.document

set oDoc=oWord.Documents.add("c: emplate.dot")
oWord.visible=true

That worked fine

I installed windows xp on my machine and now that I've made a new project when I try to do the following
I get an error that says: method "Add" of object "Documents" failed

Does anyone know what do I have that problem?

I would appreciate an answer.Thank you!

Visual Basic Automate Word
I am trying to automate bringing in a template into word and
filling in fields, I have loaded the library 9.0 in VB 5.0. I
know there some examples on Microsoft but I would like
to see a complete reference of all of the controls , properties
and method listed with sintax and explainations. Does that
exist anywhere ?

Visual Basic Application For Word
Hi All,

wondering if anyone can help me with this?

I writing a macro for Word
and I have a commandbar button which toggles on and off by clicking on it

Problem is that i want the button to toggle only for the active document. (right now, iit toggles for all open word documents)

I used the code below to toggle just the control on the active document but it didn't work ....

Set Button1 = Word.ActiveDocument.CommandBars("Formatting").Controls("MyButton")

Button1.State = msoButtonDown

Any help is appreciated
Many Thanks in advance!

Microsoft Word And Visual Basic
I tried to create an OLE control and load a Word document. the problem is that when the form containing the ole control appears, the document is loaded but when i try to modify it, the File menu from Word doesn't appear. is there any way to execute a normal Word Application inside a form using an OLE control or without using it??

One more thing: i try to draw the ole control as wide as the screen but when i modify the wocument, it changes size. Why is that?

Uriel (From Argentina)

MS Word Visual Basic Editor
Hi,

Just wondering is there any difference between the Visual Basic compiler and the MS word Visual Basic editor??

Jerry

Using Word Application From Visual Basic
Hi,

I am writing a VB application which needs to open the Word application and then open a particular document in the Word application.

I am able to open the document and close it as I need. When I do the above, I get an error "The memory could not be written" while close the document. When I try the same by debugging the code, the application is working fine.

Can anyone give me suggestions for the above?

Thanks,
Anitha

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