![]() With a filename with spaces, you get ""filename.jpg"" With a filename with no spaces, you get "filename.jpg" When you want to continue the code excecution, press F5 (or F8 to step line, by line) the code will pause at that point and you can look at the variable values. Now put your cursor in the End With line at press F9 - this will set a breakpoint. In the VBE, select View>Locals - this will show the Locals window that displays a list of all the local variables while the routine is running. To find out whats going on, you look at the value of your string variable in each case. This is caused by illegal characters in the file name - but spaces are perfectly valid. I am no word expert by any means but I think you will have to rename your pictures so that they don't have any spaces.maybe someone will come along and correct me.I have the same problem with your code.Īs far as getting the caption below the picture, try adding a carriage return between your insert picture and insert caption code. I have taken the liberty of enclosing your code in vba tags.just select your code when posting and hit the "Wrap VBA tags button" The code 'Position:=wdCaptionPositionBelow' positions the caption at the bottom right of the picture but I would prefer it to be underneath it.ĭoes anyone have any ideas or suggestions? Any help would be much appreciated. If I try to insert a picture with a filename that contains spaces then I get a run-time error '5152'.Ģ. Selection.InsertCaption Label:="Figure", TitleAutoText:="", Title:=": " & picName, _ġ. PicPath = CurDir 'picPath holds the picture path By surfing the net to find example macros and piecing together the relevant bits, here's what I've come up with so far: I am a VBA novice trying to write code to insert a picture and the filename as a caption.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |