Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2011, 03:56 AM
tinfanide tinfanide is offline VBA: How to control Word ListGalleries in Excel? Windows 7 64bit VBA: How to control Word ListGalleries in Excel? Office 2010 32bit
Expert
VBA: How to control Word ListGalleries in Excel?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default VBA: How to control Word ListGalleries in Excel?


Code:
Sub test()

Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Dim wrdDoc As Word.Document
Set wrdDoc = wrdApp.Documents.Add

Dim wrdTbl As Word.Table
Set wrdTbl = wrdDoc.Tables.Add(Range:=wrdDoc.Range, NumRows:=6, NumColumns:=1)

With wrdTbl

.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
.Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
.Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
.Borders(wdBorderRight).LineStyle = wdLineStyleSingle
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
.Borders(wdBorderVertical).LineStyle = wdLineStyleSingle

For r = 1 To 6
    .Cell(r, 1).Range.Text = ActiveSheet.Cells(r, 1).Value
Next r
End With

' Dim temp3 As ListGalleries
For r = 1 To 6 Step 2
Set temp3 = wrdApp.ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
With temp3
    .NumberFormat = "%1."
    .TrailingCharacter = wdTrailingTab
    .NumberStyle = wdListNumberStyleArabic
    .NumberPosition = CentimetersToPoints(0.63)
    .Alignment = wdListLevelAlignLeft
    .TextPosition = CentimetersToPoints(1.27)
    .TabPosition = wdUndefined
    .StartAt = r
End With
Dim rng As Range
Set rng = wrdDoc.Range(Start:=wrdDoc.Range.Rows(1).Range.Start, End:=wrdDoc.Range.Rows(6).Range.End)
rng.ListFormat.ApplyListTemplate ListTemplate:=temp3
Next r

End Sub
The above codes work well in Word VBA but not in Excel.
Don't know why so difficult to use ListGalleries in Excel to control Word...
Have found millions of entries online but could hardly find one.
Could anyone please help a bit? I'm desperate...
Near nil online coverage on Word VBA...

Last edited by tinfanide; 12-13-2011 at 04:44 AM.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA: Control Word Table and Set its properties tinfanide Excel Programming 0 12-10-2011 09:06 AM
VBA: How to control Word ListGalleries in Excel? is there file 'version' control in excel keithg Excel 1 11-14-2010 07:51 AM
Control how Excel Opens slew0302 Office 0 02-03-2009 01:30 PM
MS Word Field Tab Control? mycon73 Word 0 09-24-2007 07:46 AM
Excel ->VB code for Checkbox (control toolbox) kirkstyle Excel 0 08-16-2006 04:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:15 PM.


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