Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-08-2018, 08:05 AM
Plycc100no Plycc100no is offline Can I clear the contents of a table using VBA Windows 10 Can I clear the contents of a table using VBA Office 2013
Novice
Can I clear the contents of a table using VBA
 
Join Date: Jun 2018
Posts: 1
Plycc100no is on a distinguished road
Default Can I clear the contents of a table using VBA

Hi - I'm used to using VBA in excel but new to Word although I appreciate they should be similar.

My issue is that I have a word doc with VBA that sends the doc as an attachment through outlook. I've copied and pasted it but that bit seems to work ok.



The issue is that it is not sending through any amended contents (which I believe is due to the doc not being saved before emailed) so what I was going to do was add a line in to save the doc and then attach.

The doc contains two separate tables which I would like to know if I can clear the contents of 1 column in after the document is added to the email so I can save again in its original state.

ie
user completes tables and runs VBA
document saved
added to email
clears contents of table
document saves

I can't seem to work out how I would reference the 2 tables to clear the contents. In excel I would name a range etc but can't see how to do similar in Word.

My current code is

HTML Code:
Private Sub CommandButton1_Click()
Dim olkApp As Object
Dim strSubject As String
Dim strTo As String
Dim strBody As String
Dim strAtt As String
    strSubject = "Testing"
    strBody = "<p style='font-family:arial;font-size:12pt'>" & "Please see the attached document." & "</p>"
    strTo = xxxxxxxxx@xxxxxx.com
           
    strAtt = ActiveDocument.FullName
    
    Set olkApp = CreateObject("outlook.application")
    With olkApp.CreateItem(0)
        .OriginatorDeliveryReportRequested = True
        .To = strTo
        .Subject = strSubject
        .HTMLbody = strBody & vbCrLf & vbCrLf
        .attachments.Add strAtt
        '.send
        .Display
        
        
    End With
    
    ActiveDocument.Close _
 SaveChanges:=wdSaveChanges, _
 OriginalFormat:=wdOriginalDocumentFormat
    Set olkApp = Nothing
End Sub
As I say, this was "borrowed" from something else so any advice that could be given to improve etc would be gratefully received.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I clear the contents of a table using VBA Table of contents JasonMichelM Mail Merge 4 09-15-2017 06:31 PM
Creating a Table of Contents in a table format Ellymoo Word 9 06-22-2017 08:15 AM
Table of contents with section breaks (text in table in header) Dmonk Word 2 05-23-2017 04:29 AM
Can I clear the contents of a table using VBA Move table cell contents from one table to another table or cell in same table donaldadams1951 Word VBA 4 02-04-2015 03:54 PM
Can I clear the contents of a table using VBA Table with Table of Contents as a Column dynamictiger Word Tables 4 07-21-2014 10:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft