Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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