PDA

View Full Version : Create PowerPoint HOs to formatted Word document VBA



chazmac
11-14-2014, 10:44 AM
hello,

i often produce Word documents through PowerPoint's create HOs in MSWord function. it's great the Word document is a table with 3 columns because i use the same column setup.

can a macro be created that would:
1. change the column widths to .94" (left), 2.82" (center) and 2.69" (right)
2. add a .5pt border on the right and left side of center column
3. replace slide objects with .jpeg, .png or .tif pictures located in folder on hard drive. inline shapes
4. and then place .5pt border around only those pictures in center column

i can only figure out small bits and pieces and that's through the macro recorder.

any help will be appreciated.

thank you,
chazmac

fumei
11-14-2014, 08:07 PM
For beginners (and we all were at one time), that is the way to do it. Record bits and pieces and then put them all together.

Show us what you have done so far.

chazmac
11-16-2014, 10:20 AM
hi fumei,

this is it so far. some recorded, some written (probably badly), some outright stolen. the column width portion functions but the widths are wrong. after running, left = .79, center = 2.67 and right = 2.54" it also changes the margins to 1.00" and 1.2" from 1.00" and .75". the document has mirrored margins as most of mine do. replacing the slide objects with with .jpeg, .png or .tif pictures, i have no idea how to even record that :( i'm confused!!!!

any insight is appreciated.

Sub ZZZZZZ()'
' ZZZZZZ Macro
'


Selection.Tables(1).Select
Selection.Columns(1).Width = InchesToPoints(0.94)
Selection.Columns(2).Width = InchesToPoints(2.82)
Selection.Columns(3).Width = InchesToPoints(2.69)


With Selection.Tables(1)
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With


'PURPOSE: Add borders around all images in the document


Dim myPic As InlineShape


'Loop Through All Pictures (aka Inline Shapes) in Document
For Each myPic In ActiveDocument.InlineShapes

'Border Thickness
myPic.Line.Weight = 0.5
'Border Line Style
myPic.Line.Style = msoLineSingle
'Border Color
myPic.Line.ForeColor.RGB = RGB(0, 0, 0)

Next myPic


End Sub