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

How To Open Word Template?

I need to open a word template when a user hits the button. Then i need to add info to the document and save it as a different name.

Not sure how to specifically open a template.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Open Word Template
Is there a way to open a word template, make some and replace changes and then prompt the user to save the template as some other document?

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("")

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

How To Open A Specific Word Template.
Hi, I'm trying to cut my programming teeth on a little side project at work.

Situation: I want to be able to call up a specific MS Word template from within an Access database. I modified some code that I found on this site and can at least get Word to open a blank document marked "read only" but not the specific document I want.

Here is the code so far:

Private Sub OpenWord()
Dim WordApp As Word.Application
Dim WordTemp As Word.Template
Dim STRTempName As String
STRTempName = "\fltntshr001ITG_CommonIT ServiceeFDNDealer AlertsDealer System"
Set WordApp = New Word.Application
Set WordTemp = WordApp.Documents.Open(STRTempName)
WordApp.Visible = True
End Sub

Thank you to the original author and thanks greatly for any help in advance to you all.

Open MS Word Document/template Through VB6
Hi all, I am writing the following code to open a word template

Code:Dim objWord As Word.Application

Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open App.Path & "", , , True, , "password"

The word template is password protected. This code does open the template file from VB6 but code macros of the template does not run. While I try to run the template directly, a vba form opens in the start up but when I open it through VB6 it does not evokes the form. Any guidance please...

Help - Need To Open And Read A Word Template From VB
Hi !!!

I have a Word Template file ( *.dot). which will have a text box and check box taking user input. i have to open that *.dot file and read the values given in the text box and check box and insert the values in to the should i do it from VB.please help me in solving this problem.

Open A Word Template Save And Close

I have some problem here figuring this out, , the plan is to open a template word file, write some data, SaveAs with new filename then close it. this code has some problem with it.

Set wdQE = New Word.Application
If UCase(cbxReportTemplate.Text) = "RIFFA" Then
wdQE.Documents.add (App.Path & "")
wdQE.Documents.add (App.Path & "")
End If

Call create_QEDoc(flvwsuppliers.TextMatrix(flvwsuppliers.Row, 1), flvwsuppliers.Row)

Dim oDoc As Document

Set oDoc = wdQE
oDoc.SaveAs "C:ProcEmailAttach" & txtRFname & ".doc"
oDoc.Saved = True

thanks in advance...

Open A MS-Word Template And Replace Some Text
I got some code of how to open MS word within VB6, that's ok, but my question is, once I had that doc or template which is what i want ( a template), open, what do I have to do to update the template with the info. retreived from a data-base?........

Open Word Template, Create New Document
How do i open a word template and create a new document from it?

There's like 20 parameters when opening a word.application,,,,,,...... Mark P.
Providing Low Cost Powerful Point of Sale Solutions.

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")
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 & ""

'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
Debug.Print "Going to save as " & strSaveName
.ActiveDocument.SaveAs strSaveName
.Selection.EndKey Unit:=wdStory
End With

Exit Sub

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

End Sub

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

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
.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?

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:

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?

Access To Word: Closing And Opening Word Template
Hi there,
following Function is calling from Access and opens a Word-Template to replace the Bookmark with a Teststring. No Problem, but by a second Call, the Bookmark is not found cause the Worddocument is open in Background (although its closed with "objWord.Quit SaveChanges:=False"). IS there a better Way to close a Worddocument or did anybody find another mistake in that Code? I'm a Newie in VB/Word and I hope this is a clear Description of that Problem.

greetz & Thanks

Public Function test() As Long
    Dim MyRange As Range
    Dim objWord As Word.Application
    Set objWord = CreateObject("Word.Application")
    objWord.Visible = False
    objWord.DisplayAlerts = 0
  Dim oDoc As Word.Document
  Set oDoc = objWord.Documents.Open(getDbPath() & "Templates", ReadOnly:=True, ConfirmConversions:=False, AddToRecentFiles:=False)
  If ActiveDocument.Bookmarks.Exists("TEST") Then
    ActiveDocument.Bookmarks("TEST").Range.Text = "ABCDEFG"
    ActiveDocument.Bookmarks.Add Name:="TEST", Range:=Selection.Range
  End If
savEnv = objWord.Options.PrintBackground
objWord.Options.PrintBackground = False
objWord.Options.PrintBackground = savEnv
objWord.Quit SaveChanges:=False
Set objWord = Nothing
test = 1
End Function

Open Template
Hi everyone,

I'm trying to open a new document based on a template that I created from VB6.
My template is in the 'User Templates' folder for MS Word.
The only way I was able to do that is by creating a dummy doc based on my template, opening that doc, then opening AttachedTemplate, closing dummy doc. This kind of works, but there's got to be a shorter way to open the template.

Thanks for your help.

Open Template In VB6

I have a template named BLANK.xlt and what i am hoping to do, is, when i run my app, i would like my template to appear on screen everytime the app is opened, but, at the moment I am struggling on how i can do this.

When the app, and template is opened, the user will (hopefully) be able to add items into the cells of my template and once finished, save the edited template as their new document.

Can anyone please give me advice on how i can achieve this

Many many thanks in advance

VBA Word Template Word 2000
Help Please!!!

I have written a Letter template an once launched a user form pops up giving you the option to type in your details. Now this all works okay but when you save the template and then re-open the template The userform does not appear allowing you to make chnages to the template. Is there any code or a way in VBA you can get the userform to launch and to load all the informtion first typed into the userform?

Here is my code in the 'My Document' part.

On Error Resume Next
Dim oform As frmletter
Set oform = frmletter

oform.txt10.Text = Format$(Date, "d mmmm yyyy")

If oform.Tag = "OK" Then
' updating bookmark called "TO"
Dim bmrangeTo As Range
Set bmrangeTo = ActiveDocument.Bookmarks("To").Range

bmrangeTo.Text = oform.txt1

ActiveDocument.Bookmarks.Add _
Name:="To", _
Set bmrangeTo = Nothing

' updating bookmark called "TO1"
Dim bmrangeTo1 As Range
Set bmrangeTo1 = ActiveDocument.Bookmarks("To1").Range

bmrangeTo1.Text = oform.txt1

ActiveDocument.Bookmarks.Add _
Name:="To1", _
Set bmrangeTo1 = Nothing

' updating bookmark called "ADDRESS"
Dim bmrangeAddress As Range

Set bmrangeAddress = ActiveDocument.Bookmarks("Address").Range

bmrangeAddress.Text = oform.txt2

ActiveDocument.Bookmarks.Add _
Name:="Address", _
Set bmrangeAddress = Nothing

' updating bookmark called "YourRef"
Dim bmRangeRef1 As Range

Set bmRangeRef1 = ActiveDocument.Bookmarks("YourRef").Range

bmRangeRef1.Text = oform.txt8

ActiveDocument.Bookmarks.Add _
Name:="YourRef", _
Set bmRangeRef1 = Nothing

' updating bookmark called "OurRef"
Dim bmRangeRef2 As Range

Set bmRangeRef2 = ActiveDocument.Bookmarks("OurRef").Range

bmRangeRef2.Text = oform.txt9

ActiveDocument.Bookmarks.Add _
Name:="OurRef", _
Set bmRangeRef2 = Nothing

' updating bookmark called "DATE"
Dim bmRangeDate As Range

Set bmRangeDate = ActiveDocument.Bookmarks("Date").Range

bmRangeDate.Text = oform.txt10

ActiveDocument.Bookmarks.Add _
Name:="Date", _
Set bmRangeDate = Nothing
Set oform = Nothing


Set oform = Nothing

End If
End Sub

Thank you in advance.

I Want To Open An Excel Template?
I know that if I have a command button in the following:

Private Sub Command2_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Application.Visible = True
Exit Sub
End Sub
Then I'll have a brand new Excel spreadsheet to transfer over data.
I have two questions.

1.) How can I pull up a template instead of a whole new document?

2.) How can I pull up a certain file instead of a new document?

Thanks for any help!

I appreciate it!


Open Normal Template In Vb6
Ok...when you open visual basic editor in word will open you a NORMAL project himself. how do i open this NORMAL project in vb6 or where is this project for proggraming the normal template of word


Template Doesnt Open :(
I'm trying to write a template...Now I've followed the steps as described on: and saved it all as document template. But if I open the document template, nothing happens (the vba form doesnt appear)..what am i doing wrong ? plz see attachment

Open As Template, Save As Doc
Hi there,
If I open a document as a template, et but then save it with a unique name, eg. word1.doc then how do I close all instances of word?


Open Template In The Excel

How do I open the template from Excel using VB ?

Template In Word
Hello all,

I am trying to sort out a template in Word which will set up a template for a
letter - I want it to work so that a box pops up and you type the
address of the recipient in, and the same for other bits in the text of
the letter- and these are then put in the right place on the page. Any
ideas how to do it ?

I know some VB so a push in the direction would be more than helpful.


How Do I Add A Template To A Word 03 Doc?
what is a templates extension?

what would be the code to add a saved template into a word doc and if possible add it at a certain area like the end of the doc


and i have searched i couldnt find any code for adding a template

Word Template

I was wondering if the following is possible:

I have several word templates in a folder
In my (vb 6) project I let the user choose which templates he wants to edit (by a checkbox)
[Now my question:]
I want to open all checked templates in 1 new word document (like you open en copy the content of the selected templates in a new word document)

How do I do that? (sample code is greatly appreciated)

Big thanks in advance!!

VB6 And Word Template
I have an ascii text database that is a fixed length type, I created a user type to access the db, I created a "template" in Word for a mass mail letter. I can access the records information in the db and pass it to the word template. The problem is - when I get to the next record and pass the information (ie: name) it will add it to the same page and name filed in the word document. I need to add a page with the same text and fields from the original template, then add the new record info, go on to the next record and repeat until finished adding as many pages as needed.

Example of what shows in the word document after just 2 records are selected.

Dear John Smith Betty Crocker of 123 Main Street 432 South Street
Here is what we show for your current City and State - City1,ST City2,St2

I need it to read:

Dear John Smith of 123 Main Street
Here is what we show for your current City and State - City1,ST

<end of page>
<new page>
Dear Betty Crocker of 432 South Street
Here is what we show for your current City and State - City2,St2
<end of page>

(Without the <end of page> <new page> of course

Any help would be greatly appreciated - Thanks

Word Template
I have to create more than 3000 word documents, based on a template, using visual basic.

for i = 1 to 3000
Set WordDoc = m_WordApp.Documents.Add("")

It takes a lot of time to create the document, so I would like to know if there is a way to use a template which would be in memory instead of loading it from the disk.

I already tried WordDoc.AttachedTemplate without success.

Could someone help me ?

Word Template
I have a program that opens a Word template and inserts certain information into bookmarks on the Word document.

Dim objWord As Word.Application
Set objWord = New Word.Application

'Open SubmittalData coverpage and import data
Documents.Open FileName:="P:Submittal"

How do you open a new document based on the template instead of opening the actual template? I don't want the users to be able to accidentally change the template.

Word Template Help
need to create an email template that takes the content(+ header and footer) and send it to lotus notes and allows the user to email someone with the entire look of the original document

Word Template
I'm creating a Template word document as like:
However, once the template is saved & closed, the next time it is opened it still requests macro's to be enabled due to the reference to the original .dot file,

Is it possible to remove this link in the VBA code of the original document once complete, or prevent word from requesting for macros?

Word Template

I'm new to Word Macros. However, I have a template that needs to be populated via a form. I was wondering what is the best way to do this, shall I place the text from the form into text fields on the document, these text fields must contain an address block, name etc.

Cos in excel its simple just place the value of the text box into a cell. However, I am unsure how to approach this.

MS Word Template

I've made a template in MS wordt
Is it possible to fill the fields with VB6?

Best regards

Template (word Or Pdf)
Is there a way to use a template (say a travel form or something business related) and while in VB6 a user can print out the form with user inputs on it.

Word Template
Dear All

How to save word template information into Sql server?
i have word template with 5 fields say emp no, name, address, phone no
& remarks columns. i want to save these fields info into Sql server database
once after saving word template or once after selecting any button in the
word template by using VBA.

Please send if any one having sample code with word template

Thanks & regards,
Sridhar CS

Word Template To XML
I want to write a VBA script that will take the contents of a document and convert it into some html or XML. I don't want to use the "save as web page" function, but write my own.

I write a lot of technical documents and Word is good for doing this. I'd just prefer the output in XML and I want to avoid all the extra formatting the "save as" option puts in as I'll be applying my own style sheet later.

Microsoft have their own method shown on their web site, but it's crashed everytime I've used it.

Has anyone ever done the same thing, as I don't want to reinvent the wheel if I don't have to?




Using MS Word Template
Hi gurus!

I made a MS word template.
What I'd like to implement is,
In VB, copy template file(*.dot) to word document file(*.doc).
And I'll handle *.doc by application object, document object and selection object in VB.
But in case of saving *.doc file, do not have to affect to template file.
How can I implement it?
Is it Ok for me to copy template file to word document file simply?
Could anybody let me know?


Word New Template
Hi ,

We are using one central for all users.
Now I want to set some toolbars when opening this

I have written some code in the document_new and document_open and everything is working fine.

BUT it is only working when I click on New or open document. I want to run my code totally in the startup of Word.
I thought it was calling the document_new procedure but this is not the case .
Can somebody help me with this ??

Thanks a lot !!!

Change Template Of Doc Without Open Winword
I need to change the linked template of a Worddocument without having to open the document in Winword. CAn someone please help me out ??

Open A New Document Read-only Template
I am opening a new document on my own customized template from my vb program and everytime i close it it asks me if i want to save changes to the document and to the do i make the template readonly so that it doesnt ask me if i want to save changes to it?

here's my code:

Dim doc As String
Dim temp As String

temp = App.Path & ""
doc = App.Path & "Doiciméad 1.doc"
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = True
wdApp.ActiveDocument.AttachedTemplate = temp
wdApp.ActiveDocument.SaveAs FileName:=doc

DLL/COM Redirection From A Word Template?
Hi there. Can I pick some brains, please?

I need an application of mine to use an old version of the Rich Text control without replacing the new one for others, so DLL/COM redirection looked just the thing, but this is described as working for DLLs/OCXs loaded from an application .EXE file.

My application is launched from a Word template. That template references a DLL which references another DLL which references a custom OCX which makes use of the Rich Textbox control.

Is there any way I can get this VBA-launched app use a local version of the Rich Textbox control like DLL/COM redirection is supposed to work for an .EXE app?


Insert Word Template(s)
I am writing a small application in word that displays a userform and allows the user to select which documents they wish to include. Is it for a statement of work and the user will choose what categories of work is being performed. So I have the user form the user checks which sections they want but when I use the .Documents.Add command it opens a new doc for each of the sections I want. I wish to add to the end of the original.

Any thoughts?


* Printing A Ms Word Template In Vb *
hey everyone -

for an application i am currently working on, i want there to be a notification printed when a user clicks on a mnuChangePasswordNotice precedure that i have made in msword [the notification itself], notifying that a user is in need to change their password in order to use the application.I was wondering if
someone could take a look at my code and give me any suggestions as to
what i might be missing - fortunately i am not getting any errors of anykind when i run the application and test it out, but nothing is being printed on the paper.

thanks ahead of time.

Private Sub Password_Notice(ByVal recInformation As ADODB.Recordset)
Dim start As Single, PauseTime As Integer
Dim wrdobject As Word.Application 'specific declarion for early binding

Set wrdobject = New Word.Application 'create word object

'open the template document created earlier
wrdobject.Documents.Open FileName:="A:Phase2_Projectchange password notice.doc"

With wrdobject.ActiveDocument
'use word's bookmarks collection to recieve the data from recInformation
.Bookmarks("FirstName").Range.InsertAfter recInformation!fldFirstName
.Bookmarks("LastName").Range.InsertAfter recInformation!fldLastName
.Bookmarks("Password").Range.InsertAfter recInformation!fldPassword
.Bookmarks("UserID").Range.InsertAfter recInformation!fldUserID
'print report
End With

PauseTime = 10 'time required for printer to print document
start = Timer
Do While Timer < start + PauseTime 'allow printing to complete before word quits


'close object; no need to save document
wrdobject.Quit SaveChanges:=wdDoNotSaveChanges
Set wrdobject = Nothing 'destroy object

End Sub

Word Template Question
I have made a word template that looks like this:

some text



some more text

The template engine (coded for my vb6 program) replaces the values (1 to 3), what I want to implement with vba code: on the place of [sum-of-all-values] the sum of value 1 to 3 should appear after the template engine has done its work.

How do I do that? I never worked with macros or vba code in word.
Can you help me out?

Big thanks!!

Note: the sum cant be computed with my vb6 program, it has to be done from within the word document.

Word Template Not Closing
I'm having a problem with using a Word template in my VB app.

What I'm trying to do is take a word document with a bookmarked section, inserting and populating a table, saving it as a new file with the appropriate naming convention, then opening the new file up for the user.

First run through, and it works great. The new file is created and opened properly. If I close the file and generate it again, it re-writes the doc and opens it up without an error.

The problem occurs when the user already has the Word doc open when a new one is being generated, which could occur if he generates the doc, goes make to the app to edit, then re-generates. The user gets the appropriate error message, which is triggered when it tries to save over the open doc, but the Word file being used as a template is left open. If the user again tries to generate, it tells him that the template file is locked, and all hell breaks loose.

What I need to do is ensure that if the user has a copy of the final document open, that the app properly closes the templaet file when giving the error message. I have tried adding "Set wApp = Nothing" and "wApp.Quit" to the error handler, but the template file remains open.

Any suggestions?

Private Sub cmdGenerate_Click()
Dim wApp As Word.Application
Dim wTable As Word.Table
Dim sSaveAsName As String
Dim iRowCount As Integer

On Error GoTo Err_Handler

Screen.MousePointer = vbHourglass

iRowCount = 20

sTemplatePath = AppPath & "TemplatesTerms.doc"
sSaveAsName = AppPath & "Terms" & OpportunityNumber & "-" & iVendorID & ".doc"

Set wApp = CreateObject("Word.Application")
With wApp
.Documents.Open (sTemplatePath)
End With

Set wTable = wApp.ActiveDocument.Tables.Add(wApp.Selection.Range, iRowCount, 1)
With wTable
' Code to fill the table
End With

wApp.Visible = False
wApp.ActiveDocument.SaveAs sSaveAsName ' Error 5356 occurs here if the save file is already open
Set wTable = Nothing

Set wApp = CreateObject("Word.Application")
wApp.Documents.Open (sSaveAsName)
wApp.Visible = True

Screen.MousePointer = vbDefault

If Err.Number = 5356 Then
MsgBox (sSaveAsName & "is already open.")
Set wTable = Nothing
Screen.MousePointer = vbDefault
End If

End Sub

Word Template Issue
I have been merrily designing a new vb template so they have a screen to enter in letter details etc in word. I've just discovered (remember I'm a vb novice) that rather than then merging it into a flat document, it infact keeps the template with it. Thus causing a drama with the way our system works (long story)

So, the short story, is there anyway of "detaching" the vb form from a resulting document?

Word Template Reference
I am curious about whether I can do this, I hope I explain it well enough:

We have several document templates already existing on our system, and I was wondering if after a new document is created it can be determined whether it was based on one of them. When I look at it, I can see it contains a reference to the template in question but I don't know if it's possible to determine that via code. Basically, what I need to do is create a macro that will do one thing if the document was based on a particular template and something else if it was not.

Access Into Word Template
Is it possible to set a word document up with variables and then somehow retrieve the variables from an access database and print the resulting pages?

for example can i have a form setup in word, and if i choose a name, it will fill out the form with the appropriate information and then print it?

How To: Create A Doc From A Word Template
Hi guys, i'm sure this is simple but i spend to enough time, i have to ask. I have a procedure that opens a word template, makes some changes a shows it to the user. The thing is, that it's the template that actually opens, so if the user save changes, the next time it executes, the document will show old data plus the new changes.

How can i do to create q new doc based on the template? (whitout opening the template)

Heres the code i'm using right now:

VB Code:
Public Sub SendToWord(ID As Integer)DoEvents 'someone tell me to put this, but i have no idea what it doesDim wordApp As ObjectDim wordDoc As ObjectDim wordRng As ObjectDim Cot As clsCotizaciones, xCot As clsCotizaciones_ItemsDim Cli As clsClientes, Productos As clsProductosDim C As Byte Set Productos = New clsProductosSet Cot = New clsCotizacionesSet Cli = New clsClientes If Not Cot.GetReg(ID) Then Exit SubIf Not Cli.GetReg(Cot.IDCLIENTE) Then Exit Sub Set wordApp = CreateObject("Word.Application")wordApp.Documents.Open FileName:=App.PATH & ""Set wordDoc = wordApp.ActiveDocumentSet wordRng = wordDoc.Content 'IDwordRng.Find.Execute FindText:="COTIZACIÓN  #", _                     ReplaceWith:="COTIZACIÓN  #" & Str(Cot.ID), _                     Wrap:=1                     'FechawordRng.Find.Execute FindText:="Fecha de cotización:", _                     ReplaceWith:="Fecha de cotización: " & Cot.FECHA, _                     Wrap:=1 'ContactowordRng.Find.Execute FindText:="Contacto:", _                     ReplaceWith:="Contacto: " & Cli.CONTACTO_NOMBRE & " " & Cli.CONTACTO_APELLIDO, _                     Wrap:=1 'Razon SocialwordRng.Find.Execute FindText:="Cotizar a:", _                     ReplaceWith:="Cotizar a: " & Cli.RAZONSOCIAL, _                     Wrap:=1 'Observación:wordRng.Find.Execute FindText:="Observación: ", Wrap:=1If wordRng.Find.found Then    wordRng.MoveStart Unit:=4, Count:=1    wordRng.InsertAfter vbCrLf & vbCrLf & Cot.NOTAS    wordRng.Font.Name = "Arial"End If  C = 2 For Each xCot In Cot.ITEMS    If C > 2 Then wordDoc.Tables.Item(1).Rows.Add        wordDoc.Tables(1).Cell(Row:=C, Column:=1).Range.Delete    wordDoc.Tables(1).Cell(Row:=C, Column:=1).Range.InsertAfter Text:=Productos.GetField(xCot.IDPRODUCTO, "NOMBRE")        wordDoc.Tables(1).Cell(Row:=C, Column:=2).Range.Delete    wordDoc.Tables(1).Cell(Row:=C, Column:=2).Range.InsertAfter Text:=for_sig(xCot.PRECIO_NETO, xCot.DOLAR_FLAG, 4)        wordDoc.Tables(1).Cell(Row:=C, Column:=3).Range.Delete    wordDoc.Tables(1).Cell(Row:=C, Column:=3).Range.InsertAfter Text:=CStr(xCot.CANTIDAD)        wordDoc.Tables(1).Cell(Row:=C, Column:=4).Range.Delete    wordDoc.Tables(1).Cell(Row:=C, Column:=4).Range.InsertAfter Text:=for_sig(xCot.PRECIO_NETO * xCot.CANTIDAD, xCot.DOLAR_FLAG, 4)        wordDoc.Tables(1).Cell(Row:=C, Column:=5).Range.Delete    wordDoc.Tables(1).Cell(Row:=C, Column:=5).Range.InsertAfter Text:=Productos.GetField(xCot.IDPRODUCTO, "ENTREGA")     C = C + 1Next wordApp.Visible = True Set wordApp = NothingSet wordDoc = NothingSet wordRng = NothingSet Cot = NothingSet Cli = NothingSet xCot = NothingSet Productos = Nothing End Sub

well, thanks!


Word Document Template
Hey all, i'm trying to make a word document template that looks good.. i am transfering data from my vb program onto a word document for printing. I can do that just fine but i'm lacking the certain something that makes my print out look good and eye catching. So far i can only do the basics such as new lines and making it bold. I have an address which should be on the top right and all the data from the form should be centered but in line. The problem i had with that was that my data kept coming out jagged making it look messy.

Any help would be much appreciated!

Thanks a lot


Detect Word Template Name From Vb6
I'm trying to detect the filenames from opened word or excel documents and templates.
Documents are ok but with templates I don't know how to do.

Background: I would like to make a service which runs in the background and performs certain actions when the user opens a .dot or .xlt file. When this happens I want to detect the name of the template. The templates and documents are not opened from VB.
I started to use:

Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Call GetWindowText(hwnd, ByVal sString, 255)

The sString gives me the filename if it is a .doc or .xls. Example:
Offer.doc - Microsoft Word
Microsoft Excel - Address.xls

But in the case of a template I only get texts like:
Document2 - Microsoft Word
Microsoft Excel - Book21

How can I retrieve the actual template name instead of the unsaved document name?

Is there another way to do this?


Resolved: VB6 To Word Template
I am looking for code that will take information from a VB screens text boxes and place them into a bookmarked Word template.

Any help would be appreciated,


Code by Hack = Saaaweeeeeeeeeet

Copyright © 2005-08, All rights reserved