Position an open notepad window relative to dialog control

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,885
Office Version
  1. 365
Platform
  1. Windows



Hi Excelers
I'm opening a notepad file (.txt) from within a dialog sheet which is active, and want to position the top of the notepad window relative to a line of
dropdownboxes on the userform.
don't know how to refer to the notepad window to position it.
Can anyone point me in the right direction please?

This is what I'm using to open the notepad:

Code:
AppActivate (Shell("NOTEPAD.EXE " & {filename here}, vbNormalFocus))

and this to target the position of the dropdown (which works fine):

Code:
(DialogSheets("nameofsheet").DropDowns(10).Top)

Thanks, in advance

 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Sykes

The only way I can think of doing this would be via Windows API.

Why are you opening notepad? Could you not use another approach?

By the way are you using a dialog sheet from Excel 4.0? Why not just use a userform?
 
Upvote 0
Hi Norie

Well spotted on the dialogsheet! It's an old project that I started about 5 or 6 years ago, and was teaching myself Excel from scratch.
There's an interpolation task some of us are required to do at work, and I wondered if I could get Excel to do it for me. Time went on, and my project grew and grew as I taught myself more and more.
The project was well recieved at work,and has been used ever since. I'm still upgrading from time to time, but the dialogsheet in question remains because it has got over 40 dropdowns and editboxes in it, and I can't bring myself to re-do all of the code for handling the data. It still works fine anyway, so my motto is, if it aint broken don't try and fix it...........

One of the procedures which works with the dialogsheet is fired by a button, and populates some of the editboxes with data which it extracts from a notepad file.
It's very important that my chaps be displayed the contents of the original file as soon as the dialogsheet has been populated with the data, so that they can visually inspect it and confirm that the correct data has been extracted.
There are also other items of data in the notepad file which don't get extracted, but they need to have sight of.

They can, of course just click the window frame and move the notepad to the necessary place......... but you know when you've got a project 99.9% and your just striving for that last .1% to make it bang on......

I've done searches for API calls but have not found anything easily adaptable yet, which I understand enough to use!!

Will keep searching and report back for others if I find what I need.

Thanks for the response
 
Upvote 0
Sykes

Why not just display the contents of the file in a textbox?
 
Upvote 0
Hi Norie

I could do that, yes, but I've got to the stage where I want to learn more, and I've seen quite a bit about API calls, so this is probably the best time for me to start reaching outside the scope of the workbook (not that I've achieved any more than a basic profficiency inside it!)
If it all goes pants then I'll probably leave it like it is, or use your idea of a text box (presumably on a displayed userform) the position of which I'll be able to manipulate quite easily.

Thanks again



 
Upvote 0
Sykes

Well the API's you probably want are SetWindowPos and FindWindow.
 
Upvote 0
Norie
Thanks for that
I'll have a butchers when time permits

regards
 
Upvote 0

Forum statistics

Threads
1,203,181
Messages
6,053,964
Members
444,695
Latest member
asiaciara

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