I've written a Word macro that creates a file dialog which allows the user to select a photo. I do that because I want to bring that photo into a new blank document they can use as an editing canvas to crop and resize the photo, then click a button to transfer that over to the main document. But when I insert the photo programmatically into the temporary editing document, it always comes in with landscape orientation, even if in the file picker it shows as portrait.
My guess is all jpg files start in landscape, but can be rotated to portrait by the user when in a file preview program like Windows explorer. If you manually insert a picture in Word using regular ribbon commands, it knows to preserve the portrait rotation. But when I use VBA to add the selected picture, it does not recognize the rotation, and always comes in landscape. Is there a property I can access that tells me whether the photo has been rotated relative to its original orientation, so I can mimick that after importing?
Set reportdoc = ActiveDocument
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.Title = "Select Photo"
fd.Filters.Add "Pictures", "*.jpg;*.gif;*.png;*.bmp;*.tif;*.tiff;*.emf;*.wmf;*.jpeg", 1
fd.InitialFileName = testprojectfolder & "\Photos\"
If .Show = -1 Then
pickedphoto = .SelectedItems(1)
Set fd = Nothing
Set tempphotodoc = Application.Documents.Add
Set selectedpix = tempphotodoc.Shapes.AddPicture(FileName:=pickedphoto, LinkToFile:=False, SaveWithDocument:=True)