mikeeez
07-25-2014, 09:37 AM
Hi!
I wrote a markro, which takes images from a folder and puts it in a word document. The makro works like a charm until it comes to the 580th image. Than it ether deletes the image while resizing it or it just not getting it from the folder, instead it puts a square character in. I have no idea what the problem is. Its even more mysterious that the same makro is working under Mac Office 2011. I hope somebody can help! Thank you!
Here is the code I'm using:
'Insert pictures
MyFile = Dir$(targetfolder & "\*.*")
Do
pn = ActiveDocument.InlineShapes.Count
targetfile = targetfolder & "\" & MyFile
MyFile = Dir
ActiveDocument.Range.Select
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "PICXX"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.Execute
End With
'paste
Call clear_clipboard
Selection.InlineShapes.AddPicture FileName:= _
targetfile _
, LinkToFile:=False, SaveWithDocument:=True
ActiveDocument.InlineShapes(pn + 1).Select
'change size
With Selection.InlineShapes(1)
If AutoScript.FormatBox2.ListIndex = 1 Then
.Height = 47.84
Else
.Height = 66.05
End If
.Width = 85.05
End With
Loop Until MyFile = ""
I wrote a markro, which takes images from a folder and puts it in a word document. The makro works like a charm until it comes to the 580th image. Than it ether deletes the image while resizing it or it just not getting it from the folder, instead it puts a square character in. I have no idea what the problem is. Its even more mysterious that the same makro is working under Mac Office 2011. I hope somebody can help! Thank you!
Here is the code I'm using:
'Insert pictures
MyFile = Dir$(targetfolder & "\*.*")
Do
pn = ActiveDocument.InlineShapes.Count
targetfile = targetfolder & "\" & MyFile
MyFile = Dir
ActiveDocument.Range.Select
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "PICXX"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.Execute
End With
'paste
Call clear_clipboard
Selection.InlineShapes.AddPicture FileName:= _
targetfile _
, LinkToFile:=False, SaveWithDocument:=True
ActiveDocument.InlineShapes(pn + 1).Select
'change size
With Selection.InlineShapes(1)
If AutoScript.FormatBox2.ListIndex = 1 Then
.Height = 47.84
Else
.Height = 66.05
End If
.Width = 85.05
End With
Loop Until MyFile = ""