Measuring distances with vba

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,392
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Can you use vba to measure distances in excel, such as between any given row at the bottom of the current page?
 
Re: "Are all the sheet2 references meant to be changed to the name of the sheet I am putting the image in?"
Yes. Change that to the Sheet Name that has the TextBox and also obviously will get the picture.
What is the name of that sheet and what is the name of the textbox?

@Mike
I assumed that he/she means the printed page. We'll wait for confirmation either way.
 
Last edited:
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Sorry Mike, I don't really follow your question.
The HPageBreaks properties being used are where there are page breaks when the user prints a page.
Are you placing the image realtive to that or are you concerned about what the use sees on screen rather than what is printed on a physical page?
 
Upvote 0
In relation to post #23 Mike, the document will need to be printed to pdf. Once it is in pdf form, if the text box was near the bottom of the page, the image will be put inserted below the text box but it will be split between the last 2 pages. I had an idea that I could measure the distance between the the bottom of the text box and the bottom of the page and if there wasn't enough room for the picture, I could insert a page break to make a new page, then insert the picture. This would mean that the image would be on the one page.
 
Last edited:
Upvote 0
So what happened when in the code from Post #13 you changed every occurrence of "Sheets("Sheet2") to Sheets("sheet1") and every occurrence of "TextBox 1" to "TextBox4"?
Note the capitalization or lack of it regarding the sheets as well as the lack of space in "TextBox4"
Normally the Sheets are named with a capital "S" unless you changed it yourself and the TextBoxes when added are with a space between the letters and the number.
 
Upvote 0
Please remind me what I was trying to achieve with post 13.
 
Upvote 0
I remember, with the code is post 13, if the references are changed, I get the error message "The item with the specified name wasn't found."
 
Upvote 0
I then press end and it inserts the image with left alignment and starting in row 7. This is right on top of my table.
 
Upvote 0
I'll leave it up to someone else.
Nothing makes sense to me anymore. I am sure it is me but that's the way it is.
Good luck
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top