Excel 2007 :: Drawing Textbox Resize Width With VBA
Feb 20, 2012
I'm using Excel 2007 and I am taking the contents of various user entered cells and creating drawing textboxes to display this data using VBA. How would I get VBA to resize the width of the textbox so that the text is displayed correctly in the textbox i.e. there will be variable lengths of text in the cells so I currenly can read the full contents?
I've prepared an excel file (excel 2007) with some tabs that contains several charts (4 to 6 charts). When I want to print this file, the sheets with the charts on it doesn't print properly. I have set the print area to cover the charts only and then set it to fit on 1 page but the charts will not scale to fit.
I read somewhere that this is an excel bug - is there a workaround for this?
I could resize all my charts smaller but only as a last resort.
I have a NAMED RANGE of data consisting of 4 columns and as many rows as is selected. Name it CompTable1.
I loop through all of the 4 columns of data to format it (as shown below). This snippet is for column 1 of CompTable1 (a public variable as string) and I basically have the same situation for each column of 4 but replacing each respective x in cells.(n,X) & offset(0,-x) to take into account of where I wish the data to go as I loop through. Ultimately 4 (For Next) loops.
[Code] ......
The new range with 5 columns is as follows: Column 1 from CompTable1 = Column 1 of new range Column 2 of new range is blank for something later Column 2 from CompTable1 = Column 3 of new range Column 3 from CompTable1 = Column 4 of new range Column 4 from CompTable1 is not used in the new range but is formatted Column 5 of new range is blank for something later
This certainly works very well and with my amateur VBA status am quite proud of how far I have come in a few months. Is it efficient? Is it free of possible errors? Likely not. I wish to rid myself of the "Select" each cell plaque though maybe using a resize, offset or copy destination operation but can't seem to get it working. Once I do get the data in the new range, I format everything without selecting quite well with my methods described above.
So far my VBA will copy my range of cells in Excel and paste them into Powerpoint but I'm totally stuck as to how to resize the image from there. I've tried a bunch of different methods and I get some pretty crazy results but can't seem to punch through to a solution. What I'd like it to do, at the end of the VBA is:
Set the lock aspect ratio to false Set the Height to 5.5" Set the Width to 9.83" Set the horizontal position to .08 from Top Left Set the Vertical position to .58 from Top Left
I cannot seem to get my save as portion to work at all. I commented it out at the bottom. This is all in Excel and PPT 2007.
Here is what I have so far:
Sub Export_Excel_to_PowerPoint()
Dim ppApp As PowerPoint.Application Dim ppSlide As PowerPoint.Slide On Error Resume Next Set ppApp = GetObject(, "PowerPoint.Application") On Error GoTo 0
[Code]...
Ultimately the behavior I'm looking for with this macro is to copy a filtered range of cells from Excel and paste it as a picture into Powerpoint (up til this point I'm golden) then resize the image on the slide, save the presentation, then exit PPT.
I have a sheet with 30 textboxes made with the drawing toolbar. The user enters data, then clicks on a button which formats the page to adjust row size to match amount of info. I am having trouble finding the code to store the currently selected textbox in a variable so that I can place the focus back to the same textbox when the macro ends. Can anyone help me with the code to get the active textbox?
I have a macro that runs when a text box is clicked and searches in another excel sheet for a cell with a specified value. My problem is that I specify the string to search for in the code and I would like it to search for the string in the text box that gets clicked.
I am having a small problem with microsoft excel 2007.the problem is that: my excel 2007 cannot display tooltip of the column width when I keep and drag left mouse
Show tooltip of the column width as attached file.
I also tried many ways to find settings of advance menu. But cannot.
Is there anyway to automatically update a value in a cell to a texbox?
Eg In sheet1, there is a value of 2.3 in cell A1. In sheet2, I have a textbox created from the Drawing Toolbox. The content in the textbox would always be " Total (Sheet1.A1.value) Months"
I need to make rows expand to fit the largest text box within that row. I found the code below online, it works perfectly on the spreadsheet it came on but it doesn't work on my spreadsheet.
Dim cr As Range Dim ht As Single Dim mht As Variant Dim cn As Integer
Excel 2007, Vista. When I step through the code and hover over "Type:= msoTextBox" the tip pointer indicates a value of 17 which is consistent with the mso shape type enum for a TextBox, but Excel produces a smiley face instead.
Code: Sub TBoxAdd() Dim sh As Shape 'next line returns a smiley face Set sh = ActiveSheet.Shapes.AddShape(Type:=msoTextBox, Left:=100, Top:=100, Width:=100, Height:=100) MsgBox sh.Name 'Returns "Smiley Face #" End Sub
I have a picture in my spreadsheet which slight tilted. I want to add a text box on to that shape and add some text but i want the text to be angled the same shape as my picture.
If I create and rotate my text box manually, the default rotation makes it rotate slight to much.
I was hoping if I could add a custom drawing of a text box so the text can be the same a picture.
how to automatically set a text box size to display text contained by right-clicking the textbox and put a check in the auto-size box under "Alignment".
However I would like to set the widht of the text box and automatically adjust the height according to the number of lines of text. Is this possible by VBA code or othe means?
I have a UserForm that Dead Head Miles will be entered into one text box. The Trip Miles will be entered into the second text box I would like for the user form to show the answer after the first entries are made something like this:
1)Dead Head Miles 20 + 2) Trip Miles 500 ----times---$2.00 3)Projected Rate $1040 --show this after the DH and Trip is entered and Multiplied by $2.00
I having problem to determine the format value of dates that needs to be inserted in a Userform.
I have the following format in my userform for my Textbox:
[Code] ......
When I select the calendar in my userform that is set as follows:
[Code] .......
And select the first day of the month, it will always add the format as 05/01/2014 but if I select today’s date as example it will add it in the right format: 2014/05/26
I have included a sample to demonstrate the function of the calendar as I have declared it public as d in a module, therefore making the population of my userforms textbox easier to add information on dates.
Calendar.xlsm
If you add 2014/05/01 - 2014/05/26 and 2014/05/06 you will see where the system is having problem with the month and dates I guess the system confuses the two?
I have a text box within a chart tab which is populated with text values from a worksheet within the workbook. That part works fine however i want to be able to achieve the following example:
Current Text: Component Name - Notes
if there are notes against the component name i want the name to remain in black and the notes to change to blue
Aim: Component Name - Notes
If there arn't any notes then for the component name and the "-" to change to a light shade of grey
Aim: Component Name -
There are 26 components, each on their own lines in the textbox so im thinking either a loop where the cell reference is variable eg. ("CY" & i) or using the .find with a variable.
My code so far is:
Code: Sub Chart_Notes_NTCA() Dim i As Long, j As Long, Counted As Long, Total As Long Dim Ans As String, Notes As String Dim Cht As Chart
I have a userform with a textbox and would like the user to type inside the textbox which in turn send the text typed to a cell on my spread sheet say sheet 1 cell ref A1. I am writing the following into the control source Sheet1!A1 but the control source does not except this. I am using excel 2007 .
Any way to retrieve values from a combobox on a webpage (For my case there are two values in the combobox.) I know how to manipulate the webpage to choose the values in the combobox and so on but i want my user to be able to see the options they have from my userform.
I have a Userform that when opened shows the Excel spreadsheet sitting behind. Is it possible to write code such that when opened the Excel workbook has been sized and re-positioned such that it is effectively hidden under the Userform?
Anyhow, I enjoy the modern convenience of a dual-monitor setup but still find myself struggling with small forms(?) in Excel. For instance I am currently looking at the "Conditional Formatting Rules Manager" which occupies a very limited amount of screen real-estate. The sheet I am working on contains a large number of conditional formats which all use long custom formulas. I am not the original author.
I would love to be able to resize the overall size of the menu and the columns within it but, for the life of me, I can't seem to do so. It would be much easier to be able to see the rule formulas in one glance as opposed to having to go into each one to see the one-character difference. As stated before I certainly have the real-estate to do so.
I need to resize Excel pretty frequently - I need to size the whole Excel app tall and all the way to the left, taking up about a third of my screen - then maximize it - then back to tall and left, etc. I can do it by clicking the "Restore Down" icon in the top right corner, but I can't figure out how to do it using the keyboard.
I've tried Ctrl-F8, Ctrl-F9 and Ctrl-F10, but they all act on individual workbooks within the Excel application. I want to resize the whole Excel application. Does it exist?
I have a user here at my company that is having a strange issue with Excel. When she moves a page break in her document, Excel freezes up, then once it finally makes the change (if it doesn't crash), some (but not all) of the images that are in the document resize to super small.
For instance, she may have 50 rows. Each row contains a column with an image, then a few other columns with product information. Changing a page break may cause ten of the images to become tiny for no apparent reason. Resetting page breaks seems to cause the document to explode, with cells being thrown all over the page into different locations and columns becoming uneven.
When I make the same change on the same document on my system (both using similar specs and Office 2010), this does not happen.
From one moment to another I am not able to set the column width doing the following: right-mouse-button click (the column) and choose column width and then type in the desired width The column width is not set this way.
Setting the column width by dragging the right side of the column works well. Also double clicking the right side of the column (auto width) works fine.
I think I have pressed a certain key combination (I am not aware of) to activate this behavior.
How can I re-activate/enable the above (1st) mentioned method to change the column width?
I'm looking for a macro or function/formula to list & total a range of column widths. Having lots of columns with varying widths t'would rather not have to do it manually from each column's Properties.
How to insert the column dividers manually--for importing a fixed-width text file into excel? The files I'm having to import consist of dozens and dozens of columns.