Microsoft Office Tutorials and References
In Depth Information
Changing the Path for Graphics Files
View the Appendix to learn how to store this procedure
in a Standard module.
Option explicit¶
' * * * * *¶
Sub ShowGraphicName()¶
frmNameGraphic.Show¶
End Sub¶
' * * * * *¶
Sub MoveGraphicToPage()¶
'Variable declaration¶
Dim shp As Word.Shape¶
Dim PageNr As Long¶
Dim iPos As Long¶
For Each shp In ActiveDocument.Shapes¶
'Don't process canvas content¶
'Only valid in Word 2002, 2003¶
If Not shp.Child Then¶
With shp¶
Select Case .RelativeVerticalPosition¶
'Positioned relative to the page¶
Case wdRelativeVerticalPositionPage, _¶
wdRelativeVerticalPositionMargin¶
'Extract the page number;¶
'it's the 5th character in the name¶
iPos = 4¶
PageNr = ExtractNumber(shp.Name, iPos)¶
'Compare the current page number with¶
'the specified one¶
If shp.Anchor.Information(wdActiveEndPageNumber) _¶
<> Val(PageNr) Then¶
'Move the graphic to the correct page¶
'using the Clipboard¶
MoveGraphicViaClipboard shp, PageNr¶
End If¶
Case wdRelativeVerticalPositionLine, _¶
wdRelativeVerticalPositionParagraph¶
'It's formatted to move with the text and¶
'is therefore not linked with a specific page¶
Case Else¶
'unknown Enum constant¶
End Select¶
End With¶
End If¶
Next shp¶
End Sub¶
' * * * * *¶
'Extract a number from a string,¶
'Starting at the offset position plus1¶
'until there are no more numerals¶
Function ExtractNumber(ByVal sString As String, _¶
Wrd
Search JabSto ::




Custom Search