Using VBA I am inserting 2 pics into a Word doc at 2 bookmarks. If I use frames, the pics are inserted the same size - BUT there is a frame border. this is OK if both pics are inserted, but if 1 pic doesn't exist, it isn't inserted, leaving a blank frame.
If I use a text box, the code can't find the bookmark in the box, so that's out.
If I just put the bookmarks into a blank line, some pics are inserted with different sizes, which looks awful.
If I select a frame, the format frame menu is greyed out.
How do I remove the borders from the frames?
Remove border from a frame
-
- 5StarLounger
- Posts: 962
- Joined: 09 Feb 2010, 00:33
- Location: Patterson Lakes, Victoria, Australia
Remove border from a frame
Avagr8day, regards, Peter
-
- Administrator
- Posts: 78391
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Remove border from a frame
Try this:
Code: Select all
Sub RemoveBordersFromFrames()
Dim frm As Frame
For Each frm In ActiveDocument.Frames
frm.Borders(wdBorderLeft).Visible = False
frm.Borders(wdBorderRight).Visible = False
frm.Borders(wdBorderTop).Visible = False
frm.Borders(wdBorderBottom).Visible = False
Next frm
End Sub
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 962
- Joined: 09 Feb 2010, 00:33
- Location: Patterson Lakes, Victoria, Australia
Re: Remove border from a frame
Thanks Hans. Before I did that I again checked the doc WITH the frames and contrary to what I said before, the pics were inserted different sizes.
Using your code did remove the frame borders, but the pics still insert different sizes. This is strange as the pics are indeed the same size - 320 x 240 pixels. they just display different sizes. The para marker in each frame is the same size, Arial 12 in each case. The frames are adjacent to each other on the same line.
Any idea why they are displaying with different sizes?
If it can't be fixed is there some way the frames can be resized with VBA?
Using your code did remove the frame borders, but the pics still insert different sizes. This is strange as the pics are indeed the same size - 320 x 240 pixels. they just display different sizes. The para marker in each frame is the same size, Arial 12 in each case. The frames are adjacent to each other on the same line.
Any idea why they are displaying with different sizes?
If it can't be fixed is there some way the frames can be resized with VBA?
Avagr8day, regards, Peter
-
- Administrator
- Posts: 78391
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Remove border from a frame
Why don't you resize the pictures themselves? That way you don't need frames...
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 962
- Joined: 09 Feb 2010, 00:33
- Location: Patterson Lakes, Victoria, Australia
Re: Remove border from a frame
I currently do resize them (no choice). But the idea behind using a template is that it shouldn't need any tinkering, it should just be ready to use.
Still using the frames as I suspect that it is easier to resize a frame than a pic using VBA.
Still using the frames as I suspect that it is easier to resize a frame than a pic using VBA.
Avagr8day, regards, Peter
-
- Microsoft MVP
- Posts: 1316
- Joined: 24 May 2013, 15:33
- Location: Warminster, PA
Re: Remove border from a frame
Instead of frames, try using a table with its borders turned off. Set the table's AutoFit (at Table Tools > Layout) to Fixed Column Width. Any picture you (or your code) insert whose native size is wider than the cell width will be automatically resized to fit.
-
- 5StarLounger
- Posts: 962
- Joined: 09 Feb 2010, 00:33
- Location: Patterson Lakes, Victoria, Australia
Re: Remove border from a frame
Good idea Jay, unfortunately it doesn't work.
I have left borders showing so I can see the cells.
Both cell margins are set to 0, Both have 'Fixed Col width.
I have left borders showing so I can see the cells.
Both cell margins are set to 0, Both have 'Fixed Col width.
You do not have the required permissions to view the files attached to this post.
Avagr8day, regards, Peter
-
- 5StarLounger
- Posts: 962
- Joined: 09 Feb 2010, 00:33
- Location: Patterson Lakes, Victoria, Australia
Re: Remove border from a frame
Ha, ha. setting the col widths to the same - 2.25 didn't stick, they ended up as 2.51 and 2.21. Hence the different sized pics.
Made them the same width and it looks like we have a winner.
Thanks Jay.
Made them the same width and it looks like we have a winner.
Thanks Jay.
Avagr8day, regards, Peter
-
- Microsoft MVP
- Posts: 1316
- Joined: 24 May 2013, 15:33
- Location: Warminster, PA
Re: Remove border from a frame
Good show!
BTW, there's a button on the same ribbon for "distribute columns" that will make all selected columns the same width, equally dividing the total width.
BTW, there's a button on the same ribbon for "distribute columns" that will make all selected columns the same width, equally dividing the total width.