Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

VBA Word Macro [Closed]


  • This topic is locked This topic is locked

#1
getdigitalz

getdigitalz

    New Member

  • Member
  • Pip
  • 1 posts
Hello. I'm having problems writing a macro for Microsoft Word. It's supposed to remove all paragraph returns except the last one, so the document becomes one block of text.
I learned VB in school, but I don't know much about VBA. I've been using this site for reference.
I've been trying to use this loop.
Dim lBaseTotal As Long
lBaseTotal = ActiveDocument.Characters.Count - 1

' Create one paragraph of text
Selection.HomeKey Unit:=wdStory
For n = 1 To lBaseTotal Step 1
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    If (Selection.Text == "^p") Then
        Selection.Delete Unit:=wdCharacter, Count:=1
    End If
    Selection.MoveRight Unit:=wdCharacter, Count:=1
Next n
The problem is with the if statement, as VBA won't let me use '=='.
I also tried using find in a loop to the end of the document, but that just gets stuck on the last character. ^^;; Since it is a paragraph return.
Any suggestions? Thanks in advance.
---
Edit: Figured out a different loop. ^_^

Edited by getdigitalz, 12 August 2005 - 10:31 AM.

  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
if i remember correctly, u can use the .Selected property to check for similarities
or cant u go = insytead of ==

i know that in java u have to go == not =

my vbskills have dwindled, im more into java

ill close this topic at your request

plz message if u want back up plz do not repost

{topic closed}

Edited by stu_design, 15 August 2005 - 09:14 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP