excel vba tabstrip is it possible to left align the tab captions? - vba

I have a tabstrip, with a couple of tabs with
.style = fmTabStyleButtons
.TabOrientation = fmTabOrientationLeft
I can't seem find anything to change the alignment of the button captions. The captions are all justified within the button. With .font I can change the font, the weight and the size, but no alignment.
Is it possible at all? A solution without vba would also be ok.
Thx Kaz

Related

Can font size and style be dynamically changed at the same time?

I'm trying to create a form that allows the user to edit text on another form, however only the size OR style (bold, italic etc.) of the font is changed instead of both.
My current code:
fnt = Form1.Label6.Font
Form1.Label6.Font = New Font(fnt.Name, 12)
Putting FontStyle.Bold after means that size will only be bold. This is the same for regular and italic. I have a feeling I'm overlooking something simple but i just can't figure it out.
Thank you

How to set a cells vertical alignment in a table in PowerPoint with VBA?

Using VBA in PowerPoint I am trying to set a cell (within a table) it's Vertical alignment property. In PowerPoint this property can be accessed via "Layout" (when focus is on the cell), click Cell Margins, click Custom Margins. You'll see Vertical Alignment there.
I have figured out how to change the internal margins:
With objTable.Rows(the_row).Cells(the_col).Shape.TextFrame.MarginLeft = ' value in points.
Thank you
You can access and change it this way:
objTable.Rows(the_row).Cells(the_col).Shape.TextFrame.VerticalAnchor = msoAnchorMiddle
https://learn.microsoft.com/en-us/office/vba/api/powerpoint.textframe.verticalanchor

How to prevent RichTextBox to change alignment automatically?

I am programming a text editor and I use richtextboxes.
In one of the richtextboxes I need the text aligned to the right, so I use:
RTB.SelectAll()
RTB.SelectionAlignment = HorizontalAlignment.Right
RTB.DeselectAll()
And it's ok, the text is horizontally aligned to the right. The problem is when I do any change (for example, pasting some text or any other change) all the text in that RichTextBox gets automatically aligned to the left again (originally it was left aligned).
What should I modify to prevent the text to align again to the left after I have applied right alignment?
Thanks.

Reapplying macro font change to chartarea does not work

I have some code which changes all texts in a chart object to a specific size and font. Thing is the first time one runs the code it works like a charm. But if I change any part of the text within the chart and then re-run the code nothing happens.
E.g I run the code, then change the title heading to size 15 and font arial, then rerun macro, and nothing happens.
What can be wrong?
My code
With Selection
.Format.TextFrame2.TextRange.Font.Size = 10
.Format.TextFrame2.TextRange.Font.Name = "Times New Roman"
.Format.TextFrame2.TextRange.Font.Bold = msoFalse
End With
When you apply the fonts/sizes to the ChartArea in order to propagate them down to the individual pieces, Excel stores that info at the CharArea level. If you make a change to the one of the components (ChartTitle, Axis, etc.) and try to run your code again, there is no change on the ChartArea. Seems that Excel does not propagate those changes "back up". This makes sense since now the different items are styled differently.
The easiest way to deal with this is to reset the styles before you make your changes. ClearToMatchStyle applied to the Chart (i.e. ActiveChart or Selection.Parent in your context) will do it. It appears it will also make the change if you use a different font size or actually make a change to one of the ChartArea.Format properties (e.g. Size, Name, etc.).
Code for the reset option
ActiveChart.ClearToMatchStyle
With Selection
.Format.TextFrame2.TextRange.Font.Size = 12
.Format.TextFrame2.TextRange.Font.Name = "Times New Roman"
.Format.TextFrame2.TextRange.Font.Bold = msoFalse
End With

Scrollable image in userform

I have a word doc with a bunch of ActiveX Control buttons or whatever on it, and each time a button is clicked, a corresponding image needs to be displayed in a popup box.
I have a userform called ImageForm, and this is what I'm doing right now:
Sub Button_Clicked()
ImageForm.Picture = LoadPicture("appropriate_image_path")
ImageForm.Show
End Sub
Each of these images has a width of 8.5 inches, but their heights can vary anywhere from like 3 to 20 inches (they're snippets of a pdf). So I've set the width of the userform to a little more than 8.5 inches, and that looks fine. But I need to be able to scroll vertically through the image in the userform, since some of the images could be taller than a user's monitor.
I'm completely stuck on this. What I've tried so far is adding a frame to the form, then adding an image control inside the form, and setting the "ScrollBars" property of the frame to vertical. Then instead of using "ImageForm.Picture = ..." I use "ImageForm.ImageControl.Picture = ..." But it doesn't work.
Any insight here would be greatly appreciated. Hopefully this question is clear enough, I've only been using VBA for a month or so now. (I miss Java so, so much)
Thanks!
Here is a neat little trick based on one of my posts
The idea is to ensure that the image control is in frame control and the image control doesn't have a border. Also the image control's PictureSizeMode is set to fmPictureSizeModeClip so that we can scroll the image
SNAPSHOT (DESIGN TIME)
SNAPSHOT (RUN TIME)
CODE
Private Sub UserForm_Initialize()
With Frame1
'~~> This will create a vertical scrollbar
.ScrollBars = fmScrollBarsVertical
'~~> Change the values of 2 as Per your requirements
.ScrollHeight = .InsideHeight * 2
.ScrollWidth = .InsideWidth * 9
End With
With Image1
.Picture = LoadPicture("C:\Users\Public\Pictures\Sample Pictures\Desert.jpg")
.BorderStyle = fmBorderStyleNone
.PictureSizeMode = fmPictureSizeModeClip
End With
End Sub