babsiee
10-31-2012, 04:10 AM
Hi Guys,
my macro works perfectly on a pc. It's been tested and worked correct. But when I try to run it on a mac it gets an error.
Even when I try to record a new macro on my mac it gives an error.
The error is in this part of the code:
Selection.InlineShapes.AddPicture fileName:="/Users/username/logo.jpg", _
LinkToFile:=False, SaveWithDocument:=True
The runtime error says '5152'. But I'm absolutely sure that the path of the filename is correct. Even tried to do it with '/Volumes/Macintosh HD' in front of the path but still no succes.
Hope anyone has an idea why my macro won't work.
Here is the entire code:
Sub TITLE()
Application.ScreenUpdating = False
Dim Shp As Shape
With Selection.Sections(1)
Set Shp = .Headers(wdHeaderFooterFirstPage).Shapes.AddPicture _
(FileName:="/Users/username/logo.jpg", LinkToFile:=False, SaveWithDocument:=True)
With Shp
.WrapFormat.Type = wdWrapBehind
.LockAspectRatio = msoTrue
.Width = CentimetersToPoints(21)
.Left = -70
.Top = -35
End With
Set Shp = .Footers(wdHeaderFooterPrimary).Shapes.AddPicture _
(FileName:="/Users/username/logo.jpg", LinkToFile:=False, SaveWithDocument:=True)
With Shp
.WrapFormat.Type = wdWrapBehind
.LockAspectRatio = msoTrue
.Width = CentimetersToPoints(21)
.Left = -70
.Top = -124
End With
End With
Set Shp = Nothing
Application.ScreenUpdating = True
End Sub
my macro works perfectly on a pc. It's been tested and worked correct. But when I try to run it on a mac it gets an error.
Even when I try to record a new macro on my mac it gives an error.
The error is in this part of the code:
Selection.InlineShapes.AddPicture fileName:="/Users/username/logo.jpg", _
LinkToFile:=False, SaveWithDocument:=True
The runtime error says '5152'. But I'm absolutely sure that the path of the filename is correct. Even tried to do it with '/Volumes/Macintosh HD' in front of the path but still no succes.
Hope anyone has an idea why my macro won't work.
Here is the entire code:
Sub TITLE()
Application.ScreenUpdating = False
Dim Shp As Shape
With Selection.Sections(1)
Set Shp = .Headers(wdHeaderFooterFirstPage).Shapes.AddPicture _
(FileName:="/Users/username/logo.jpg", LinkToFile:=False, SaveWithDocument:=True)
With Shp
.WrapFormat.Type = wdWrapBehind
.LockAspectRatio = msoTrue
.Width = CentimetersToPoints(21)
.Left = -70
.Top = -35
End With
Set Shp = .Footers(wdHeaderFooterPrimary).Shapes.AddPicture _
(FileName:="/Users/username/logo.jpg", LinkToFile:=False, SaveWithDocument:=True)
With Shp
.WrapFormat.Type = wdWrapBehind
.LockAspectRatio = msoTrue
.Width = CentimetersToPoints(21)
.Left = -70
.Top = -124
End With
End With
Set Shp = Nothing
Application.ScreenUpdating = True
End Sub