How do delete an specific page in a word document using Excel VBA

0 votes

When this code is executed, no error notice is returned, but the word page content is not removed as intended. What am I overlooking?

With wDoc
    .GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Name:="20" 'Page number
    .Bookmarks("\Page").Select
    With Selection
      .Delete
    End With
End With

I'd like to remove a certain page from the word document I've created and filled up using Excel VBA. I deleted using the following method:

Nov 21, 2022 in Others by Kithuzzz
• 38,000 points
1,555 views

1 answer to this question.

0 votes

Check the code below. I eliminated the quotation marks from this name parameter (replaced "20" with 20) Instead of the Activedocument that I have used, you can use the wDoc document reference.

With ActiveDocument
    .GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Name:=20 'Page number
    .Bookmarks("\Page").Select
    With Selection
      .Delete
    End With
End With

I hope this helps you.

answered Nov 21, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How do I insert a WebP-image (".jpg") in Excel using VBA?

It's not currently on the list of ...READ MORE

answered Nov 15, 2022 in Others by narikkadan
• 63,600 points
749 views
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,600 points
1,345 views
0 votes
1 answer

How can I find and replace text in Word using Excel VBA?

Try this code Option Explicit Const wdReplaceAll = 2 Sub ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
4,955 views
0 votes
1 answer

In excel how do I reference the current row but a specific column?

Put a $ symbol in front of ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
1,923 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,211 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,662 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
906 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,053 views
0 votes
1 answer
0 votes
1 answer

How to stick an embedded document in a specific cell of an excel

Solution Select the documents (you can use the ...READ MORE

answered Oct 18, 2022 in Others by narikkadan
• 63,600 points
701 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP