Microsoft Word Macro to Maximize Picture Size to Page Width

The Microsoft Word macro below will maximize picture size by resetting it to its original size.
If the original size is larger than page width and height, it will reduce it accordingly.

To create the macro, open View ribbon in Microsoft Word then click Macro > View Macro.

Type MaxPictureSize in Macro Name then click Create.
Enter the macro code text below into the editor then Save and close the macro editor window.

Sub MaxPictureSize()
	Selection.ShapeRange.WrapFormat.Type = wdWrapInline
	Selection.ClearFormatting
	With Selection.PageSetup
		Xvar = .PageWidth - .LeftMargin - .RightMargin
		Yvar = .PageHeight - .TopMargin - .BottomMargin
	End With
	With Selection.InlineShapes(1)
		.ScaleWidth = 100
		.ScaleHeight = 100
		.LockAspectRatio = msoTrue
		If (.Width > Xvar) Then
			.Width = Xvar
		End If
		If (.Height > Yvar) Then
			.Height = Yvar
		End If
	End With
End Sub

After then, create shortcut button to the macro by customizing Ribbon.

Comments