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




Word 2000: Delete A Word Page With VBA


I have a Word 2000 Template that has a bunch of bookmarks and a Data Entry Form, that the user creates a New Document off of. When the user creates a new document based on this template, there is a Macro that the user can run that loads a user entry Form allowing the user has to enter data. When the user clicks the OK button on the form the following 2 things happen:
    1. All the bookmarks within the document get updated based on data from the User Entry Form
    2. At the end of the document, a particular Word document (Test.doc) is inserted at the "Attachment" bookmark

Everything works fine the first time the user clicks the OK button. However, if the user reruns the same macro within the same document, re-enters different data on the user entry form and clicks the OK button, all the bookmarks update properly, but the inserted file gets added after the 1st one (the 1st one does not get cleared out) - so the user has 2 inserted files. For instance, the first time the user runs the letter there is 3 pages (2 pages + 1 File), and if the user runs it again, there will be 4 pages (2 pages + 2 Files - 1st one and now the 2nd one), and so on... Basically, each time the user clicks the OK button, the appropriate file keeps getting appended to the end.

My problem is, how can I remove the file (Test.doc) that was inserted on the 1st run before we insert the file on the 2nd run? Is there a way to delete the entire page before we insert the file, that way all the data is cleared leaving me with only 2 pages, before I do my insert? My sample code of inserting the file is below:

    Dim bmRange As Range
    ' This is my bookmark where I want to add the file
    Set bmRange = ActiveDocument.Bookmarks("Attachment").Range
    With bmRange
        .Collapse Direction:=wdCollapseEnd
        ' Insert a Page Break after the bookmark so that file being inserted is on it's own page
        .InsertBreak Type:=wdPageBreak
        ' Insert the Test Document
        .InsertFile FileName:="C:Test.doc", Range:="", _
        ' ConfirmConversions:=False, Link:=False, Attachment:=False
        .Collapse Direction:=wdCollapseEnd
    End With




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Delete Page In Word From VB
Hi ALL!

This is my first thread in this forum so I hope that I am in the right place.

I am using VB6 to create reports in Word 7-11. The templates that I use contains all pages necesseray for a complete report, however sometimes I only want the first and third page. How do I delete one page the best way?

Regards

/DD

MS Word 2000 VBA - Delete Blank Pages
Hi! I'm having trouble trying to create a macro in MS Word 2000 VBA. I am trying to write some code to cycle through an entire document and delete any page that is blank. There are no empty paragraphs on these blank pages, just basically a ton of extra blank pages.
Thanks for any help!

Inserting An Image On Every Page In MS Word 2000
I'm trying to put an image on every page in Word 2000 but for the life of me I can't seem to do it. I've tried to use the AddPicture object but to no success. With the AddPicture object it only adds the image to the 1st page. What I'm doing is a loop where a page break is issued then the AddPicture command finally some text then the loop starts over again. The loop is looping records in a SQL database. Any alternatives? I've tried the AddOLEObject but it seems to be worse.

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: Add The Minimize Maximize Button To A Word Form
Using VBA and possibly the AppendMenu API, has anyone had any success adding the Minimize and Maximize button next to the X (Close) button in the upper right hand corner of a Word Form?

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

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?

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?

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.

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?

Word - Loop Through Each Page In Document And Copy Page With Page Format
Here's what i'm trying to accomplish

1 - Start at first page and get page format (portrait/landscape)

2 - Copy page and paste it into a new word document with original format

repeat these steps until all pages have been copied

I need the condition where a document has both portrait and landscape pages.

Anyhelp would be appreciated

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")
oform.Show

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", _
Range:=bmrangeTo
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", _
Range:=bmrangeTo1
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", _
Range:=bmrangeAddress
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", _
Range:=bmRangeRef1
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", _
Range:=bmRangeRef2
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", _
Range:=bmRangeDate
Set bmRangeDate = Nothing
ActiveDocument.Bookmarks("StartHere").Range.Select
Set oform = Nothing

Else

Set oform = Nothing

End If
End Sub

Thank you in advance.
TonyD

Difference Of VBA In Word 2000 And Word XP [Please Help]
I have a .net application in C# that intracts with microsoft word. Previously it was designed for win xp and office xp. Now I would like this to work on Win 2000 and office 2000. But it is giving some problem.

I looked into the code and could figure it out that some functions are giving exceptions. Following are examples.

1. Document.SaveAs method works in Word XP but not in Word 2000. However Document.SaveAs2000 works in Word 2000.

2. Range.PasteAndFormat works for Word XP but not for Word 2000. However Range.Paste() works in Word 2000.

Is there any reason behind this. Is it somewhare mentioned in Microsoft website?? Could you please get me some link where this information is mentioned.

Are there some other functions that behaves similar to above mentioned?

Thanks in advance.
Ashish



edit: moved from .NET Newbies forum as it's not about .NET specifically



Edited by - Machaira on 4/26/2006 5:45:48 AM

Mail Merge Access 2000 With Word 2000/XP And Pass Variables
Hi, I debated posting in newbies, because I'm kind of learning VBA on the fly, and am not very good at all.

I am trying to Mail Merge an Access 2000 database with Word 2000 & Word XP.

I modified the code I got from the Microsoft Solution Base to try to introduce variables to allow me to merge more than one table and SQL query with more than one Word document.

This code works without the variables, when I just type everything directly. Unfortunately, I need the ability to merge multiple documents/tables.

Sorry if its sloppy code, I haven't really got much of an idea of what I'm doing in VBA yet.
Can anyone help me debug this, and maybe give me the syntax to use in my Macro for MergeIt(var,var,var)

I also need a way to email similar form letters. This is for a membership expired notice - some get mailed/faxed, so need to be printed, while some should be emailed. I've read that sendobject doesn't do so well. - is there a way to merge into Word (or Outlook) and automatically email these notices?


Thanks very much!!
--------------------------------------

   
   Function MergeIt(docaddy, sqltable, sqlstr)
    
    DoCmd.SetWarnings False
   
     DoCmd.OpenQuery "Dues Expired Calculate"
     DoCmd.OpenQuery "Dues NOT Expired Calculate"
     DoCmd.OpenQuery "Dues Are Expired"
    
    Dim objWord As Word.Document

    Set objWord = GetObject(docaddy, "Word.Documents")


        ' Make Word visible.

    objWord.Application.Visible = True

    ' Set the mail merge data source.

    objWord.MailMerge.OpenDataSource _

       Name:="F:workooo dbOOO Main Database.mdb", _

       LinkToSource:=True, _

       Connection:=sqltable, _

       SQLStatement:=sqlstr

    ' Execute the mail merge.

     objWord.MailMerge.Destination = wdSendToNewDocument

     objWord.MailMerge.Execute



'The following line must follow the Execute statement because the

'PrintBackground property is available only when a document window is

'active. Without this line of code, the function will end before Word

'can print the merged document.



     objWord.Application.Options.PrintBackground = False

     objWord.Application.ActiveDocument.PrintOut

End Function

------------------------------------

Thanks for any help!




Edited by - case on 7/31/2003 7:40:22 AM

A "word" About Changing Page Orientation In Word When Using VB6
I recently wrote a subroutine package to allow me to generate Word documents on the fly. When using it, I came across a problem that drove me crazy for a while - I am posting this to save others the headache I had.

The problem was that occasionally the top, bottom and side margins went "screwy." Example: even though the top and bottom margins were set to 1 inch and .5 inches respectively, and the right and left margins were both set to .5 inches, when the document was generated, the right margin was 1 inch and the rest .5 inches. In most cases, it worked properly, but occasionally I got this strange result.

The issues is that if you are going to change the page orientation to landscape from portrait (or visa-versa), you need to do it BEFORE you change or set the margins. While this is probably not technically accurate, the following visualization explains what is happening:

Assume you have a portrait oriented document. When you set the top, bottom, right and left margins (or any combo thereof), everything is okay. If you then change the document orientation to landscape, its almost as if the page its rotated 90 degrees (rather than shortened and widened). The two sides rotate around and become the top and bottom and the original top and bottom have rotated to become the sides. The margins STAY attached to their original top and bottom (which are now sides) and boths sides (which are now the top and bottom) after the rotation - the result is you get "screwy" margins.

Because of the combinations of changing margins and orientations in different orders, it took me a while to figure it out. Simply changing the orientation first fixes the issue.

I hope this makes sense and helps ....

Jim

Page Number && Page Count In Word (automation)
I think I've searched quite everywhere for this, and I haven't found any information at all. I want to be able to write (in VB) the page number and page count in the footer of a Word document, using Automation. I can alreay write the page number OR the page count, but not both, and I can' t add text to the footer.

I want something like "Page 2 of 5" in the footer of every page of the Word document, but I can't seem to get the hang of it, and I've run out of options. Thanks to anyone taking the time to read this post, and many thanks to anyone with a possible solution!

Raggart

How Can I Select ONE Page Of A Multi-page Word OLE Document?
Hello,

I have the following code that works just fine as long as I have a Single-page word document loaded. However, I need to Select EACH page individually and rasterize into a TIF image. You will note that I am able to Find Text and Select the Entire Line. I can also Select the ENTIRE document using the "OLE1.object.Content.Select" method. But I just can't seem to figure out how to select a Single Page!!!


Once I use the ".Copy" method I AM able to "Paste" it into my Imaging Viewer (Pegasus ImagXpress) object. It is critical that I save these pages individually. Here is the code I'm using for this:
Code:
Private Sub Command3_Click()

    OLE1.DisplayType = 0 ' Display object in the control
    

    OLE1.CreateEmbed "C:Merged.doc", "Word.Document"
    
    OLE1.DoVerb vbOLEActivateGetFocus
    OLE1.SizeMode = vbOLESizeStretch
     
    'Find Text
    With Selection.Find
        .ClearFormatting
        .MatchWholeWord = True
        .MatchCase = False
        .Forward = True
        For i = 1 To 10
            .Execute FindText:="Client Account #:"
            DoEvents
            If .Found Then
                With Selection
                    .EndOf unit:=wdLine, Extend:=wdSelStartActive
                    ' Copy the selection to the Clipboard
                    .Copy
                    ' Paste the entire selection into the Text1 form field
                    Text1.Text = Trim(Clipboard.GetText)
                    ' Break out the Account # and paste it into the Text2 field
                    Text2.Text = Right(Text1.Text, Len(Text1.Text) - InStrRev(Text1.Text, ":"))
                End With
            End If
            DoEvents
        
            'Select the entire document
            OLE1.object.Content.Select
            
            With Selection
                .StartOf unit:=wdGoToAbsolute extend:=wdline
                'Copy selection to clipboard
                .CopyAsPicture
            End With
            DoEvents
          
            Form2.ImagXpress1.Paste
            MsgBox Form2.ImagXpress1.ImagError ' Shows Zero if No Error
            Form2.ImagXpress1.Refresh

            Form2.Show
            
            DoEvents
            'Goto next page
            Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext
        Next
    End With
     
' OLE1.Close
    
End Sub

Thanks,
Jacob



Edited by - JacobRusso on 11/18/2003 5:05:10 PM

I Need To Extract The Page Number From The Current Page In Word
I need to extract the page number from the current page in word and put it in to the variable pgNum

HELP!!

Word XP Vs. Word 2000
I have an application that writes information off a sql server db to a word document into tables. When viewing these docs in word xp the tables borders dont show but when using word 2000 it does show. Why would this be? Any suggestions?

Displayed Page Number Vs. Word Page Num
I'm trying to get the page num which appears in the footer using the {PAGE} field into a VBA variable. I've tried using:

Selection.Information(wdActiveEndPageNumber)

but that returns the actual Word page number (ex: 5), rather than the {PAGE} num (ex: 2-1)

Any assistance is appreciated.

01000111

Copy From Word 2000 To Excel 2000
i have a some code that will copy all the bits that i need. but now i need a way to paste them into a excel spreadsheet.

Word - Read Page By Page
Hi guys,

I'm creating macro to send Word document as Fax to an API. From the Word template, I need to pick up three fields (Fax No, Sender Name & Subject) from each page and send the particular page as Fax. Then I need to jump to next page and select the next 3 fields and send that page as Fax.
I know how to search the fields in the document by using Code:Selection.Find.* command. But how do I read Page by Page? Currently, it always goes back to the first page when I do the search.

Please help.

P.S. The document is created by using Mail Merge and may consists hundreds of pages.

 

Delete A Word
Hello all

I would like to know how can I do to delete the last word written in a textbox pressing BckSpace Key only one time .


thank you .

What Page I'm On In WOrd
How do I figure out what page number I'm currently on in Word?

End Of Page In Word Through VB
I want to create a word document which displays the data from the database in the form of a table(with 2 columns) in the word document.I Have created a new word appliction and then added a Table in that word application through the VB Codes.The no of rows of the table varies .Hence sometimes the table Runs into mulitiple pages.The data from the database is first inserted into the first column of the table in the word document.once the first column reaches the end of page ,next the data is inserted into the second column of the same page.so I want to check when the table has reached the end of the page.so i can start inserting data in the next column of the samepage and once this column is also filled the table should be added on to the next page and repeat inserting the data the same way as above.

New Page In Word From VBA
Greetings

Your help please with this problem with Word v.9.0 VBA

I am creating a word doc from Access2000, the code loops through a recodset and makes a text box and inserts a pic. into the text box. This succeeds except that the pictures are overwritten by the suceeding records. I need therefore to create new page for each new record. However since the focus is set to a text box, upon executing the line of code which should create me a new page, I get this error: "This method or property is not available because the object refers to a text box"

Do Until EOF
Blah
Blah

Make textBox
Fill TextBox with pic
Now make a new page for next pics.

oApp.Selection.InsertBreak Type:=wdPageBreak

Loop

How can I 'deselect' the text box and create a new page is my question.

Many thanks

Word New Page
Hi

I have 3 textbox and i want to put first textbox data to the first page, the second textbox data for the second page and the thierd textbox data for the last page

I use this code but if there is no data in text2 it will give me three pages instaed of tow


VB Code:
appWord.Selection.TypeText Text:=Text1.TextappWord.Selection.TypeTextParagraphappWord.Selection.InsertBreak Type:wdPageBreak appWord.Selection.TypeText Text:=Text2.TextappWord.Selection.TypeTextParagraphappWord.Selection.InsertBreak Type:wdPageBreak appWord.Selection.TypeText Text:=Text3.TextappWord.Selection.TypeTextParagraph


What is the wrong with this code

Thank's

New Page In Word
Ok,

My program writes address labels to a Word template from a database. Avery 5160 standard labels come 30 to a page... There will be days where we have more than 30 labels, though...

My question is:

How do I create a new page in the current open template in Word, but use the same bookmarks as page 1?


VB Code:
Private Sub cmdGetLabels_Click()     Dim template As String    Dim WordApp As Word.Application    Dim WordDoc As Word.Document    Dim WordTemp As Word.Document    Dim docPath As String    Dim intTimes As Integer    Dim strLetter As String    Dim strUser As String    Dim strStatus As String    Dim docPageCount As Integer        '--> Get template and document storage path    template$ = getTemplate     ConnectDatabase           '--> Start MS Word and open template    Set WordApp = CreateObject("Word.Application")    WordApp.Visible = False    'Set WordTemp = WordApp.Documents.Open("C:Documents and Settings" & Environ("Username") & "Application DataMicrosoftTemplatesNormal.dot")    Set WordDoc = WordApp.Documents.Open(FileName:=template$, Revert:=True)      intTimes = 1   With rsCustomerTable Do Until .EOF        Select Case intTimes            Case "1"            strLetter = "A"        Case "2"            strLetter = "B"        Case "3"            strLetter = "C"        Case "4"            strLetter = "D"        Case "5"            strLetter = "E"        Case "6"            strLetter = "F"        Case "7"            strLetter = "G"        Case "8"            strLetter = "H"        Case "9"            strLetter = "I"        Case "10"            strLetter = "J"        Case "11"            strLetter = "K"        Case "12"            strLetter = "L"        Case "13"            strLetter = "M"        Case "14"            strLetter = "N"        Case "15"            strLetter = "O"        Case "16"            strLetter = "P"        Case "17"            strLetter = "Q"        Case "18"            strLetter = "R"        Case "19"            strLetter = "S"        Case "20"            strLetter = "T"        Case "21"            strLetter = "U"        Case "22"            strLetter = "V"        Case "23"            strLetter = "W"        Case "24"            strLetter = "X"        Case "25"            strLetter = "Y"        Case "26"            strLetter = "Z"        Case "27"            strLetter = "AA"        Case "28"            strLetter = "BB"        Case "29"            strLetter = "CC"        Case "30"            strLetter = "DD"           End Select            '--> Insert data in MS Word template                        If Len(rsCustomerTable!Name) <> 0 Then                WordDoc.Bookmarks("" & strLetter & "1").Range.Text = rsCustomerTable!Name                Debug.Print rsCustomerTable!Name            End If                        If Len(rsCustomerTable!Address) <> 0 Then            WordDoc.Bookmarks("" & strLetter & "2").Range.Text = rsCustomerTable!Address                Debug.Print rsCustomerTable!Address            End If                        If Len(rsCustomerTable!City) <> 0 Then            WordDoc.Bookmarks("" & strLetter & "3").Range.Text = rsCustomerTable!City                Debug.Print rsCustomerTable!City            End If                        If Len(rsCustomerTable!State) <> 0 Then            WordDoc.Bookmarks("" & strLetter & "4").Range.Text = rsCustomerTable!State                Debug.Print rsCustomerTable!State            End If                            If Len(rsCustomerTable!Zip) <> 0 Then            WordDoc.Bookmarks("" & strLetter & "5").Range.Text = rsCustomerTable!Zip                Debug.Print rsCustomerTable!Zip            End If                        rsCustomerTable.MoveNext                        vbalProgressBar1.Max = rsCustomerTable.RecordCount            vbalProgressBar1.Value = intTimes                        intTimes = intTimes + 1                    LoopEnd With         '--> Save new document and quit MS Word                MsgBox "There are " & rsCustomerTable.RecordCount & " labels to Print, " & strUser & "", vbOKOnly, "Label Count"                WordDoc.SaveAs "F:SharedCust ServProgramsLabelCreatorPlus estLabels.doc"        'WordDoc.PrintOut        WordDoc.Close (Word.WdSaveOptions.wdDoNotSaveChanges)        WordApp.Quit     Set WordDoc = Nothing    Set WordTemp = Nothing    Set WordApp = Nothing        CloseDatabase           End        End Sub

Word Page #ing
Sorry guys.. this isnt about VB, but i know someone can answer this in a second...

I have a large document in word and I need to start numbering the pages from the 3rd page and call that page #1

Where is the setting to select where to start numbering from?

Thanks
-Matt

Help With VBA (MS Word 2000)
Hello to all Forum Members ;

I have got a VBA project and I'm new to this hence badly need your help. Please note that this is not going to be an Add-In ; it will be software to work from out-side of Word Environment. Well , this is my idea because I have not developed Add-In for Microsoft Word up till. If you think Add-In will be better then please guide me in that direction.

[1] I want to Open Microsoft Word 2000 with specific Template. How can I do this ? If I open a

template in MS Word and then user writes something and clicks on Save instead of Save As , will

the word prompt to him to Save As or just the template file will be modified ?

[2] How to get the text (may be a complete document or from certain Page from Document) from the

Document which is already open in Microsoft Word 2000 ?

[3] Where can I get more information on project development or some sample source code for MS

Word 2000 development (other than MSDN) ?

Eagerly waiting for your valuable reply ...

Word 2000
I have set up a little VB code to automatically insert the date but not as a field. The language is set to English U.K. But when I run the code it changes the language to English U.S.
Err anyone know why and how to get over it?

This was the code:
Selection.InsertDateTime DateTimeFormat:="dd MMMM, yyyy", _
InsertAsField:=False

Word 2000
Is it possible (and if so, how) to read in a Word document and assign each page to be displayed on a different form?

For example, I have a 5 page Word 2000 document. I want to first determine how many pages are in the document. Then, create a form for each page and display that page. So form 1 would show page 1, form 2 page 2, etc.

Thanks
Doug

Word 2000 From VB
Hi All,

I'm trying to use Word as a 'Print Engine' from VB 6. Below is the code so far.

I have 2 problems with it.

1. on Doc.Printout, it says Margins are not set even though I have set them earlier. If I say yes to continue, it prints the title and the outline of the grid for the correct amount of records, but the content of each cell is empty.

2. while I'm still in the VB App If I attempt to print again I get the error '462 - The remote server machine does not exist or is unavailable'

Public Sub GenericTablePrint(ByVal rcsIn As ADODB.Recordset, ByVal Orientation As WdOrientation, ByVal Title As String)
Dim msword As Word.Application
Dim doc As Document
Dim myTable As Table
Dim i As Integer
Dim x As Integer
Dim Ret As Long
Const pstfName As String = "GenericTablePrint"

On Error GoTo GenericTablePrintErr

Set msword = New Word.Application
Set doc = msword.Documents.Add(, , , True)

'set the page details
With doc.PageSetup
.Orientation = Orientation
.LeftMargin = 2 'want as much of the page as poss
.RightMargin = 2
End With
'format the Document Header
With msword.Selection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.BoldRun
.TypeText Text:=Title
.BoldRun
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.TypeParagraph
.TypeParagraph
End With
Set myTable = doc.Tables.Add(Range:=msword.Selection.Range, numrows:=rcsIn.RecordCount + 1, numcolumns:=rcsIn.Fields.Count - 1)
'Set Header
For i = 0 To rcsIn.Fields.Count - 1
With ActiveDocument.Tables.Item(1)
.Cell(1, i).Range.Bold = True
.Cell(1, i).Range.Font.Name = "MS Serif"
.Cell(1, i).Range.Font.Size = 6
.Cell(1, i).Range.Text = rcsIn.Fields(i).Name
End With
Next
myTable.Rows(1).HeadingFormat = True
'set detail
For i = 0 To rcsIn.RecordCount - 1 'rows
For x = 0 To rcsIn.Fields.Count - 1
With ActiveDocument.Tables.Item(1)
.Cell(i + 2, x).Range.Bold = False
.Cell(i + 2, x).Range.Font.Name = "TimesRoman"
.Cell(i + 2, x).Range.Font.Size = 8
.Cell(i + 2, x).Range.Text = rcsIn.Fields(x).Value
End With
Next
rcsIn.MoveNext
Next
rcsIn.MoveFirst
doc.PrintPreview
doc.PrintOut
doc.Close savechanges:=wdDoNotSaveChanges
Set myTable = Nothing
Set doc = Nothing
msword.Quit
Set msword = Nothing
Exit Sub
GenericTablePrintErr:
ErrorHand.GetError Err.Number, mstfName &amp; ":" &amp; pstfName, Err.Description
Set doc = Nothing
Set msword = Nothing
End Sub

Using Word 2000 In VB 6
I have a form that will be used to open an existing Word document. I have that functionality working... sort of. Here's the code snippet...

'Using Reference to Microsoft Word 9.0 Object Library

Dim oleWordApp As Word.Application
Dim oleWordPath As Word.Document

Private Sub cmdOpen_Click()
Set oleWordApp = CreateObject("Word.Application")
Set oleWordPath = oleWordApp.Documents.Open("\codysafety proceduresSECTION 01 SAFETY AND LOSS PREVENTION PROGRAM REV. B.DOC")
End Sub

Private Sub Form_Unload(Cancel As Integer)
frmMain.Show
Set oleWordApp = Nothing
Set oleWordPath = Nothing
End Sub

This opens the document, but not before requiring notification or opening as Read-Only. I'm sure that can be taken care of in the other options that are part of the Open function. A couple of questions:

1) What are the acceptable values to give for the other options in the Open function? (ConfirmConversions, ReadOnly, AddtoRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, and Visible) I tried VBYes and VBNo, but it didn't like that.

2) What values are returned when the user presses Notify, ReadOnly, or Cancel? I need to be able to handle the doc if the user presses Cancel. This question can be negated if I can get the above working.

Thanks in advance!

VB In Word 2000
I'm doing a mail merge in word with a table in an access database.
I'm trying to get VB in word to either check or un-check a word check box depending on a boolean field in the access table. The 'Document On Open' event in word doesnt seem to run when the document is fired from VB in access, and I can't get VB in access to reference the Word control check box.

Any ideas?

Word 2000 And VB
I have a VB server app that is used to import the contents of a word document.

The app works fine for all documents except those that have macros.

Because the macro security level is set to medium the message box 'the document has macros... enable disable etc...' is displayed but because the app runs on a server there is no one to respond to this message box.

Is there anyway I can change the word macro security level from my vb app.

VB And Word 2000 Please Help
Can you help , im trying to use develope a small application in word using VB forms dont ask i know it would be just easier to developed a exe... but due to some restrictions i have to develope it through word...... ne way i want to use the filelistbox option but when trying to add it to my toolbox the option is not.. their i know on Vb its microsoftcomoncoponent5.0
how can i get this as i despratelt need to use the filelistbox.

Help With VBA (MS Word 2000)
Hello to all Forum Members ;

I have got a VBA project and I'm new to this hence badly need your help. Please note that this is not going to be an Add-In ; it will be software to work from out-side of Word Environment. Well , this is my idea because I have not developed Add-In for Microsoft Word up till. If you think Add-In will be better then please guide me in that direction.

I want to Open Microsoft Word 2000 with specific Template. How can I do this ? If I open a

template in MS Word and then user writes something and clicks on Save instead of Save As , will

the word prompt to him to Save As or just the template file will be modified ?

How to get the text (may be a complete document or from certain Page from Document) from the

Document which is already open in Microsoft Word 2000 ?

Where can I get more information on project development or some sample source code for MS

Word 2000 development (other than MSDN) ?

Eagerly waiting for your valuable reply ...



Edited by - vb_programmer on 5/21/2004 10:18:53 PM

Word 2000 VBA
I have a question with Word 2000 VBA, does anyone know how I would be able to scan through a pre-existing doc with little or no styles applied and a minimum amount of TC fields(just to make a basic TOC). During the scan, I want to look for bolded headings(mind you, the normal style is applied to the whole doc, so you see the problem I am having) and check a master list of constants I have in a separate class module...I will elaborate if this is too generic a description...

Thanks in advance,


 
J.C.

"Do or do not, there is no try."

Word 2000
Hello,
I'm trying to customize WORD 2000. I have added a menubar with a controlbutton.
When clicked on the button, I would like to show a DOCKABLE WINDOW in WORD. So the window would not be a form coming up. It should be integrated in the WORD application itself. This window would communicate with my ActiveX. I know you can create a dockable window in VB with CreateToolWindow. But this is for the VB IDE itself. The function CreateToolWindow is not available for the WORD application. Can anybody help me? I don't know if it's even possible to customize WORD in this way.



Wim Coppenolle

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