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?
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?
Deleting A Page In A Word Document
Ive set up a word object using the word.application obect and have a number of table spread across several pages. What i'd like to do is delete one of the pages or not display it under certain circumstances.
I'd of thought there would be something along the lines of:
newdoc.activedocument.page(index).delete
but there isnt. Any ideas on how you can delete pages?
How To Know If Word Document Is 97 Or 2000
Hello
Before open a word document, I need to know if I can open a doc document. I must know if it is a Word 97 or 2000 document?
Do you know how to do that?
Regards
Hubert
Protect A Word 2000 Document Automatically
Is there a way to protect an unprotected Word 2000 document when a user exits a form field? I have assigned a macro that protects the document to a form field's "exit" event procedure, but it doesn't fire when the document is unprotected -- only when protected.
Unfortunately, I need the document to be unprotected when it is opened, as I am opening it from Outlook 2000 by mail merging Outlook data into it. (Outlook won't open protected Word documents.)
When the data is merged into the Word document and the document has been activated, I would like to protect it automatically as soon as possible to prevent the user from making changes to it. (I don't want the document to be merged to a new document, as that would lose all of the field codes.)
Very grateful for any help.
Pete
Insert Vbtext Into Word 2000 Document
Just a general inquiry. Can one insert the contents of a VBtextbox into a Microsoft Word Document in a simple manner ? Reason ? My general veterinary medical database office software stores patient information as Word pages but the database program itself at the office is not very efficient when it comes to the user interface for entering patient data. I have written an interface that I like in Visual Basic but the output from this interface needs to be in Word document form to be able to store the medical record on the office system.
I could do alot if I could simply transfer the contents of a VB textbox object onto a Word page. Any easy help for a novice programmer ? I don't want to spend the rest of my life learning to program from MS Word itself.
File Conversion - Word 2000 Document To HTML.
I want to programatically convert a Word 2000 document to HTML file.
I used the code listed below, and got the msg that HTML converter is not there in my machine.
I tried various variations of this code, i always end up getting an error in the saveAs() method of word document with respect to the fileFormat property.
Please tell me how to convert Word 2000 document to HTML.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dim boolHTMLExist As Boolean
Dim strMsg As String
Dim strFileName As String
Dim fcCnv As FileConverter
strMsg = "The HTML converter is not installed. Please run setup"
strMsg = strMsg + " to install this converter."
strFileName = "<Replace with document name omitting the extension>"
For Each fcCnv In Word.FileConverters
If fcCnv.ClassName = "HTML" Then
ActiveDocument.SaveAs strFileName, FileFormat:=fcCnv.SaveFormat
boolHTMLExist = True
Exit For
End If
Next fcCnv
If Not boolHTMLExist Then MsgBox strMsg
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
How Can I Find The Position Of Bookmark In A Word 2000 Document?
I've been struggling with a particular report for a while now, and hope that the VB community can help me with this problem. I want to find the position of a bookmark or form field in a word document. (I'll explain my situation below)
I have attached a jpg with an example of what I am trying to do.
The report has a header always at the top of the first page. (I can't use a header though because I have several form fields in it, but thats no biggie). Usually, the header + body + footer will fit on a single page and nothing goes wrong. However, when the body causes the footer to go to the next page, I am required to show this footer only on the bottom of the last page of the report (which probably will never be longer than 2 pages, but I don't want to assume that).
Initially I thought this could be done with tables and continuous sections in Word, but I haven't had any luck.
Why do I want to find the position of a form field or bookmark? At the beginning and end of the footer section, I've placed textboxes. (txtBegin and txtEnd). I think that I can add a carriage return until I determine these boxes are no longer on the same page, and then I can delete the last carriage return and this footer will sit perfectly at the bottom of the page.
These are my thoughts for a solution. I'm hoping that someone can help me find a way to determine the line or page the bookmark is located on, but I would be welcome to any suggestions at this point.
Thanks for any help the vb community can provide.
Tyler Dueck
dueck@hadmacker.com
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.
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
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 <> 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.
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
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
Urgent- Word 2000 And Word 2003 Problems Using Vb6 Error Number 5941
Hi,
I have Developed a VB6 Application which adds the data from DB
to MS Word 2003 Document (With Tables and other Details).
The Program Works Fine with Word 2003
But in Word 2000 Program Generates an Error "Requested Member of Collection Does not exists"
Error Number 5941.
Does there is any Functional Difference with Word 2000 and Word 2003 ? i.e. with Objects of Word ?
Code Lines :-
oWorAapp.ActiveDocument.Tables(TableNumber).Cell(Row:=RowNumber, Column:=ColNumber).Range.InsertBefore Text:=TextToAdd
-----------------
Program Error is on above mentioned Line, Parameters values are :-->
RowNumber = 7
ColNumber = 3
TableNumber = 50
TextToAdd = "Sample Data"
If I check the Table Count then Count is 60, Row Count is 10 and Column Count is 10 (From methods of WordApp Object
Please note that this works Fine in Word 2003. If user tries to execute this exe in word 2000 then error is raised
I am Very much Thankful for all the reply's
With Regards
SmartCodar
With Regards,
SmartCodar
Edited by - SmartCodar on 9/26/2006 1:24:41 AM
Calling Word SaveAs Dialog In Word 2000 & Higher
In my VB app, I open a Word document in print preview. When the user clicks the Save button, I want to bring up a SaveAs dialog. Since our users may have Office 2000, XP or 2003, I had to use late binding when declaring the object:
Public msword As Object
Here's my Save button code:
-----------------------------
Private Sub cmdSave_Click()
If msword Is Nothing Then
Set msword = CreateObject("Word.Application")
End If
With frmTestCatSrch.msword.Dialogs(wdDialogFileSaveAs)
.Name = "tstcat.doc"
.Show
End With
End Sub
----------------------------
This works fine for PC's running Office XP (haven't tried it with Office 2003). For Office 2000, however, when you click the Save button, you go into some kind of nasty loop (title bar flashes), and you have to kill the app in Task Manager.
Is there a way to make this work for all three versions of Word?
Many thanks,
Lynne
Word VBA / Macro Problem With Print & Browser (Word 2000)
I am trying to use a macro inside the AutoOpen() event of a Word doc so that when the Word doc is opened inside IE, it will print the Word doc then close both the Word doc and the IE window. For some reason, VBA loses its reference to the doc object and IE Application object after the PrintOut line is executed. I have tried things like:
Sub AutoOpen()
MyWord.Visible = False
MyWord.ActiveDocument.PrintOut
MyWord.ActiveDocument.Close False
End Sub
or:
Sub AutoOpen()
With ActiveDocument
.PrintOut Background:=False
.Close savechanges:=False
.Parent.Quit
End With
End Sub
or:
Sub AutoOpen()
Dim MyWord As Object
Set MyWord = GetObject(, "Word.Application")
Dim IE As Object
Dim IEDoc As Object
Set IE = GetObject(, "InternetExplorer.Application")
Set IEDoc = MyWord.ActiveDocument
IEDoc.PrintOut
IEDoc.Close
IE.Quit
End Sub
But whatever I try, the Word doc prints, then throws a 4605 error about the method or property not being available because the document is in another app. Any ideas?
Thanks,
Chris
Word 2000 Macros In Word 2002 & Less Functionality?
This is a two-part question.
I've just upgraded one computer to Windows XP/Office XP from Windows 2000/Office 2000. I've been recording and editing macros since way back when Word Basic was around, although I've never needed to write my own code from scratch - until now.
I have a multitude of macros that were created (recorded) & then edited further in Word 2000 that, while they still run in Word 2002, I can no longer edit them when I need to. I get a Project Locked dialog box that says "Project is unviewable". I have another computer that still has the Windows 2000/Office 2000 config, but I cannot open them there either. Is there a solution or workaround to this?
OK, next question:
I OCR & clean up/edit long documents that have been scanned. One of the most useful functions of Word's macro capability (for my purposes, anyway) has been the ability to record finding & replacing formatted text. Now, when trying to record new macros, I'm finding that Word no longer records the formatting in either Find or Replace. The command runs correctly while I'm recording the action, but when I attempt to run the macro I've recorded, I've found that it didn't retain the formatting variables, so it deletes the text it finds instead of formatting it, or doesn't find the formatted text.
This in itself wouldn't be such a problem if I could edit the macros I've already got; I'd just copy & edit the code appropriately! Is this a drawback of the new version of Visual Basic, or is it just me?
HELP!
Word - MailMerge With VB, Word 2000 And An Access 97 Database
I have written a programme in VB that must do the following things:
- Open a Word template (Works fine)
- Open a datasource (Works fine) to a Access 97 database. (I'm not allowed to change this, so i'll have to put up with that.)
How can i prevent that Access is being opened while running the programme? I only want to show the template which uses the Access 97 database. When i tested this with Word XP it worked fine and DID not open Access, but when i tried this with Word 2000 then Access did start up. I have to prevent this because i'm not allowed to supply Access.
Does anyone have an answer to this one??
Word 2000: Underline A Word Underlines The Space Between
Word 2000:
I have the following code to select a Range object and apply underlining to
a particular word within the range. For some reason, Word is not only
underlining the word, but also the space after the word that is between 2 words. Does anyone know how I
can get it to only underline the word and not the space after it?
Dim rRange As Range
Set rRange = ActiveDocument.Bookmarks("MyRange").Range
rRange.Select
With rRange
' Underline the following word within the range
.Words(53).Font.Underline = wdUnderlineSingle
End With
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 >> Process >> 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?
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.
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
Tricky Search Of A Word In A Word Document...
I need to create a VB project that searches a word in a
Microsoft Word document, counts the number of apearences
and the page and row where the word apeared.
Ex.
Suppose I need to search the word: "please"
The result should be of this form:
please - 1/2,3 ; 4/1,13
This means that the word "please" was found in the document on the line 2 and 3 of the page 1, and on the line 1 and 13 on the
page 4.
Please tell me if this can be done. I need it ASAP.
Thanks.
Why Does This Work In Word 2000 And Not Word 1997??
Hello All,
Thanks in advance for reading...
And thanks for all the help you guys gave when
I asked about something like this before...
I was having a problem with wildcards, and I finally got it to
work, however this DOES NOT work in word 97...
This string I have finds filenames with variable suffixes.
for example, the string can be:
12345679_001.jpg or
12345679_002.jpg
(The first part stays the same, and the suffix can change)
Here is how I reference this in word 2000, and it works great
search_file_name = file_name + "*.jpg"
the "*.jpg" accounts for any sequence of 001, 002 etc,
but this does not work in word 97
what can I change???
please help
thanks again,
John
Word 2000 To Word 2002 Problems
I have having some issues going from Word 2000 to Word 2002, for some reason my code is throwing up an:
"This command is not available because no docuement is open"
Here is the code (works fine in word 2000, well some bugs but no errors):
Code:
Public Function Printsign(sign_name As String)
Dim objWdApp As Word.Application
Dim objWdDoc As Word.Document
Dim objWdRange As Word.Range
Set objWdApp = New Word.Application
Set objWdDoc = objWdApp.Documents.Open(FileName:="C:SIGN.doc")
objWdApp.Visible = True
Set objWdRange = objWdDoc.Content
With objWdRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "text"
.Replacement.Text = sign_name
.Execute Replace:=wdReplaceAll
End With
Dim strText1 As String
Dim strText2 As String
Dim i As Long
i = 40
' DOESNT LIKE THIS LINE HERE
ActiveDocument.Select
Selection.Start = 0
Selection.End = 0
Selection.MoveDown wdLine, 3, wdMove
Selection.EndOf wdLine, wdExtend
Do
strText1 = Selection.Text
i = i + 1
Selection.Font.Size = i
Selection.End = Selection.Start
Selection.EndOf wdLine, wdExtend
strText2 = Selection.Text
DoEvents
Loop While strText1 = strText2
Selection.Font.Size = i - 30
Selection.End = 0
'objWdDoc.PrintOut
Dim t As Long
t = Timer
Do While Timer < t + 3
DoEvents
Loop
objWdDoc.Saved = True
objWdDoc.Close
Set objWdRange = Nothing
Set objWdDoc = Nothing
Set objWdApp = Nothing
End Function
Using Word 2002 Commands For Word 2000
I created a program in VB.net which runs great under Windows XP with Word 2002. It creates an instance of word and writes text then saves the file in a specified folder.
I referenced the Microsoft Scripting Runtime object library in order to save the file.
I also referenced the Microsoft Word 10.0 Object Library to use Word.
I now have to install my program on a computer running Windows 98 and Word 2000. The program itself runs in Windows 98, but when I try to create an instance of Word the program crashes. Does anyone know what the problem could be and how i could fix it? Do i need to link to different libraries? Is it a problem with Windows 98 or with Word 2000 or both?
I would appreciate any help, thanks.
Run Userform From A New Word Instance, Word 2000
Hi
I want to run my userform/template application from a brand new instance of Word, even if Word is already open and documents have been left open at the bottom of the screen.
The reason for this is because by using Application.Quit wdDoNotSaveChanges (which I need to do), when I come to Exit the userform, I will lose the documents open at the bottom of the screen, which may or may not have been saved previously.
How do I go about this, and where will I need to put the code - ie if code for a new instance is put at the top of the userform, then the userform would most probably have already been generated before it reads code for the new Word instance - if you get my drift?
Do I need to add something to a macro?
As I'm new to VBA, please could any replies be fairly plain and simple.
Many thanks.
Opening MS Word 2000 And MS Word 97 In VB***RESOLVED***
Hello out there
My problem is that I have code that can open MS word document in VB, but it only opens word document very well in MS Word 2000. It gives an error when opening in MS word 97. Error number -2147417851 (80010105) Automation error. The code looks like this:-
VB Code:
Private SubDim wrd As New Word.Applicationwrd.Visible=Truewrd.Documents.Open "C:Filename" Set wrd=Nothing End Sub
This code only opens MS word 2000 document but gives an error in MS word 97. Run time error -2147417851 (80010105) Automation error.
I do not understant why it does this, it supposed to open all MS documents without a problem.
Thanks in advance.
Wizard.
SA
MS Word 98 Object Library With Word 2000
I wrote a program that uses the Microsoft Word 8.0 Object Library to write to Word documents, etc. Will that program run unmodified on a PC that has Word 2000 rather than Word 97?
Word 2000: Format Word Within A Bookmark
Can anyone tell me if this can be done. With VBA code, I want to add some text to a bookmark within my document but as I am adding the text to the bookmark, I'd like to turn on/off Bold, add Underline, add comments, etc...
I am able to do this outside of a bookmark with the Selection method, but wanted to know if I can do this with a bookmark.
My sample code to format the text of a selection is below, which I would like to be able to do the same thing for a bookmark (Notice how I can turn on/off Bold just before/after I insert my text, and turn on Comments):
With Selection
.TypeText Text:="This is my first paragraph"
.TypeParagraph
.TypeText Text:="This is my 2nd paragraph. Now I will "
.Font.Bold = True
.TypeText "BOLD some words. "
.Font.Bold = False
.TypeText Text:="Bold is now turned OFF. Now, add a comment
here"
.Comments.Add Selection.Range, "This is my comment"
.TypeParagraph
.TypeText Text:="This is my 3rd paragraph."
.EndKey unit:=wdLine
End With
Is this possible to do with a bookmark? My code to select the bookmark is: ActiveDocument.Bookmarks("myBookmark").Select
If I try the same thing using my bookmark, as I did in my above example, the text gets put after the bookmark, not within the bookmark. And, if I rerun my code over and over, I get repeating paragraphs, because the bookmark does not get cleared out, since my sample text is actually in the document, not within the bookmark.
|