If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Need VBA Help with AddTextbox
I have two "mysterious" problems concerning my use of VBA-generated
textboxes. I don't know if they're connected or not. Here's the nut of the code I'm using: dim tBoxsh as shape Set tBoxSh = ActiveWindow.View.slide.Shapes.AddTextbox(msoTextO rientationHorizontal, -16.375, 120.75, 240!, 60.5!) tBoxSh.Tags.Add "Type", "EditorComment" tBoxSh.Select With tBoxSh .IncrementTop 0.62 ' fill parameters .Fill.Visible = msoTrue .Fill.Solid .Fill.ForeColor.RGB = RGB(255, 255, 0) .Fill.Transparency = 0# ' line parameters .Line.Weight = 2# .Line.Visible = msoTrue .Line.ForeColor.RGB = RGB(255, 0, 0) .Line.BackColor.RGB = RGB(255, 255, 255) ' textbox scaling for size ' .ScaleWidth 14.8!, msoFalse, msoScaleFromTopLeft ' .ScaleHeight 1.48!, msoFalse, msoScaleFromTopLeft Question 1: If I leave the scaling instructions in, AND leave the cursor in one of the generated text boxes, AND generate a second text box, it comes out wider than the first one. If I put the insertion point someplace outside of the first textbox, and then generate a second one, it comes out the same width as the first. By expanding the widths in the AddTextBox call and commmenting out the ScaleWidth statements, this behavior went away. Question 2: My users report (and I have seen this myself, but very seldom, and not in the last 6 weeks or so) that occasionally when they generate one of these text boxes, it ends up on the screen extremely wide and narrow - extending way, way beyond the right side of the slide. This is not a freely reproducible phenomenon - anybody know what's going on there? |
#2
|
|||
|
|||
Need VBA Help with AddTextbox
A few things jump to mind.
1) Try not to program using the selection functions. It can cause some issues and is usually not required. 2) Why are you scaling the textbox? Why are you scaling it by different proportions (vertically @ 1.48 and horizontally @ 14.8)? 3) Why the IncrementTop line? You have control over the creation of this object, so why modify it so soon afer creation? Just create it the way you want. By changing the code to avoid the selection (except in determining the slide the user is editing), you can directly address ... ... the text box size in the add textbox line ... the font size (shown in the code below) ... so why the scaling? By any chance, were the text boxes that behaved differently in presentations with default shapes set to a locked aspect ratio? Sub Jenkins() With ActivePresentation.Slides _ (ActiveWindow.Selection.SlideRange(1).SlideIndex) _ .Shapes.AddTextbox _ (Orientation:=msoTextOrientationHorizontal, _ Left:=-16.375, Top:=120.75, _ Width:=240, Height:=60.5) 'Add tag .Tags.Add "Type", "EditorComment" ' fill parameters .Fill.Visible = msoTrue .Fill.Solid .Fill.ForeColor.RGB = RGB(255, 255, 0) .Fill.Transparency = 0# ' line parameters .Line.Weight = 2# .Line.Visible = msoTrue .Line.ForeColor.RGB = RGB(255, 0, 0) .Line.BackColor.RGB = RGB(255, 255, 255) 'Text & font size With .TextFrame.TextRange .Text = "This is my text box" .Font.Size = 24 .Font.Italic = True End With End With End Sub Question 1: If I leave the scaling instructions in, AND leave the cursor in one of the generated text boxes, AND generate a second text box, it comes out wider than the first one. If I put the insertion point someplace outside of the first textbox, and then generate a second one, it comes out the same width as the first. By expanding the widths in the AddTextBox call and commmenting out the ScaleWidth statements, this behavior went away. Question 2: My users report (and I have seen this myself, but very seldom, and not in the last 6 weeks or so) that occasionally when they generate one of these text boxes, it ends up on the screen extremely wide and narrow - extending way, way beyond the right side of the slide. This is not a freely reproducible phenomenon - anybody know what's going on there? |
#3
|
|||
|
|||
Need VBA Help with AddTextbox
On Mar 7, 10:17 am, "Bill Dilworth" wrote:
A few things jump to mind. 1) Try not to program using the selection functions. It can cause some issues and is usually not required. 2) Why are you scaling the textbox? Why are you scaling it by different proportions (vertically @ 1.48 and horizontally @ 14.8)? 3) Why the IncrementTop line? You have control over the creation of this object, so why modify it so soon afer creation? Just create it the way you want. By changing the code to avoid the selection (except in determining the slide the user is editing), you can directly address ... ... the text box size in the add textbox line ... the font size (shown in the code below) ... so why the scaling? By any chance, were the text boxes that behaved differently in presentations with default shapes set to a locked aspect ratio? SubJenkins() With ActivePresentation.Slides _ (ActiveWindow.Selection.SlideRange(1).SlideIndex) _ .Shapes.AddTextbox_ (Orientation:=msoTextOrientationHorizontal, _ Left:=-16.375, Top:=120.75, _ Width:=240, Height:=60.5) 'Add tag .Tags.Add "Type", "EditorComment" ' fill parameters .Fill.Visible = msoTrue .Fill.Solid .Fill.ForeColor.RGB = RGB(255, 255, 0) .Fill.Transparency = 0# ' line parameters .Line.Weight = 2# .Line.Visible = msoTrue .Line.ForeColor.RGB = RGB(255, 0, 0) .Line.BackColor.RGB = RGB(255, 255, 255) 'Text & font size With .TextFrame.TextRange .Text = "This is my text box" .Font.Size = 24 .Font.Italic = True End With End With End Sub Question 1: If I leave the scaling instructions in, AND leave the cursor in one of the generated text boxes, AND generate a second text box, it comes out wider than the first one. If I put the insertion point someplace outside of the first textbox, and then generate a second one, it comes out the same width as the first. By expanding the widths in theAddTextBoxcall and commmenting out the ScaleWidth statements, this behavior went away. Question 2: My users report (and I have seen this myself, but very seldom, and not in the last 6 weeks or so) that occasionally when they generate one of these text boxes, it ends up on the screen extremely wide and narrow - extending way, way beyond the right side of the slide. This is not a freely reproducible phenomenon - anybody know what's going on there?- Hide quoted text - - Show quoted text - Thanks for the tips and help Bill. I no longer use the scaling, in favor of setting the height and width when creating the textbox. However, when it *was* there, I noted the phenomenon of different box widths. Any idea what caused that? I can't remember now why I selected the textbox. It might have been because I was having problems showing getting the cursor/insertion point into the box? But I'll certainly remove the selection, if that's a possible cause of potential problems. Likewise, I can't remember why I put in the IncrementTop. It's been in there since day one, and once things were working I didn't go back and revise/simplufy the code. I will now, though. I don't know if anyone is using locked aspect ratios. Isn't that option set for individual shapes? Where is the global default for locking aspect ratios set? Once again, thanks for the pointers! |
#4
|
|||
|
|||
Need VBA Help with AddTextbox
I don't know if anyone is using locked aspect ratios. Isn't that option set for individual shapes? Where is the global default for locking aspect ratios set? It could be set as part of the shape defaults for a given presentation, which might account for why it appears seldom and unpredictably. Best bet, I think, would be to set it explicitly to what you want (ie, OFF). With it on, any change to the height will change the width proportionally, then changes to the width will change the height. Hair falls out. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#5
|
|||
|
|||
Need VBA Help with AddTextbox
On Mar 7, 4:27 pm, Steve Rindsberg wrote:
I don't know if anyone is using locked aspect ratios. Isn't that option set for individual shapes? Where is the global default for locking aspect ratios set? It could be set as part of the shape defaults for a given presentation, which might account for why it appears seldom and unpredictably. Best bet, I think, would be to set it explicitly to what you want (ie, OFF). With it on, any change to the height will change the width proportionally, then changes to the width will change the height. Hair falls out. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ Hi Steve: Where does one set the default shape attributes for a given pres? Alos: when this "streteched" textbox problem occurs, users (and I, myslef, when I've seen it) will normally execute the same macro again, and the textbox will show as it should. This is a very sporadic thing and it's very hard for users to recollect anything they've been doing out of the ordinary that would trigger it. IN the meantime, I've cleaned up the code somewhat, following BIll's recommendations, and we'll see if that makes the problem go away. But, dammit, I hate mysteries! Even if it goes away, I'd like to know the real cause ... |
#6
|
|||
|
|||
Need VBA Help with AddTextbox
In article . com, wrote:
On Mar 7, 4:27 pm, Steve Rindsberg wrote: I don't know if anyone is using locked aspect ratios. Isn't that option set for individual shapes? Where is the global default for locking aspect ratios set? It could be set as part of the shape defaults for a given presentation, which might account for why it appears seldom and unpredictably. Best bet, I think, would be to set it explicitly to what you want (ie, OFF). With it on, any change to the height will change the width proportionally, then changes to the width will change the height. Hair falls out. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ Hi Steve: Where does one set the default shape attributes for a given pres? Draw a shape, format it to taste, then right click and choose Set as Default. This is where Echo normally pops up to remind you to first set the defaults for text and THEN do the default shape thing. And she's right. But rather than rely on the defaults for the presentation or on changing them and annoying the troops, do it to your shapes as you draw them. oSh.LockAspectRatio = msoFalse Alos: when this "streteched" textbox problem occurs, users (and I, myslef, when I've seen it) will normally execute the same macro again, and the textbox will show as it should. This is a very sporadic thing and it's very hard for users to recollect anything they've been doing out of the ordinary that would trigger it. IN the meantime, I've cleaned up the code somewhat, following BIll's recommendations, and we'll see if that makes the problem go away. But, dammit, I hate mysteries! Even if it goes away, I'd like to know the real cause ... ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#7
|
|||
|
|||
Need VBA Help with AddTextbox
"Steve Rindsberg" wrote in message
... This is where Echo normally pops up to remind you to first set the defaults for text and THEN do the default shape thing. And she's right. heh. only when I don't skip the VBA threads. :-) -- Echo [MS PPT MVP] http://www.echosvoice.com What's new in PPT 2007? http://www.echosvoice.com/2007.htm Fixing PowerPoint Annoyances http://www.oreilly.com/catalog/powerpointannoy/ |
#8
|
|||
|
|||
Need VBA Help with AddTextbox
On Mar 7, 7:39 pm, Steve Rindsberg wrote:
In article . com, wrote: On Mar 7, 4:27 pm, Steve Rindsberg wrote: I don't know if anyone is using locked aspect ratios. Isn't that option set for individual shapes? Where is the global default for locking aspect ratios set? It could be set as part of the shape defaults for a given presentation, which might account for why it appears seldom and unpredictably. Best bet, I think, would be to set it explicitly to what you want (ie, OFF). With it on, any change to the height will change the width proportionally, then changes to the width will change the height. Hair falls out. ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ Hi Steve: Where does one set the default shape attributes for a given pres? Draw a shape, format it to taste, then right click and choose Set as Default. This is where Echo normally pops up to remind you to first set the defaults for text and THEN do the default shape thing. And she's right. But rather than rely on the defaults for the presentation or on changing them and annoying the troops, do it to your shapes as you draw them. oSh.LockAspectRatio = msoFalse How does LockAspectRatio play against: ..AutoSize = ppAutoSizeShapeToFitText ? [snip] ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================- Hide quoted text - |
#9
|
|||
|
|||
Need VBA Help with AddTextbox
[snippidydoodahsnippidiyey] oSh.LockAspectRatio = msoFalse How does LockAspectRatio play against: ..AutoSize = ppAutoSizeShapeToFitText Seems that if you're doing things manually, .AutoSize to fit text wins. That is, even with aspect locked, changing the text makes the shape change ratio. But if in code you change the size, it turns .AutoSize off. Is that the world spinning or it it just your head? ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================ |
#10
|
|||
|
|||
Need VBA Help with AddTextbox
On Mar 8, 8:00 pm, Steve Rindsberg wrote:
[snippidydoodahsnippidiyey] oSh.LockAspectRatio = msoFalse How does LockAspectRatio play against: ..AutoSize = ppAutoSizeShapeToFitText Seems that if you're doing things manually, .AutoSize to fit text wins. That is, even with aspect locked, changing the text makes the shape change ratio. But if in code you change the size, it turns .AutoSize off. Is that the world spinning or it it just your head? 'Tis my head for sure. Here's something interesting: one of my users who has had this phantom textbox (infinitely wide, zero height) show up more than once, was doing some searching on the web and found someone else who was experiencing the same problem! She's going to try to find that site again - I'd like to get in touch with that poster and compare notes on what we're each doing. That might turn up something useful - who knows. Sure wish I could duplicate the problme at will ... I'm still very goosy about the fact that two identical calls to AddTextBox with hardcoded dimensions resulted in different size boxes depending on whether the insertion bar was in a previous box or not. That indicates to me that the sizing of added textboxes is whimsical, at least, under certain undefined circumstances. Doesn't give one that nice, warm feeling about the steadfastness of the AddTextBox method operations. Nitey-nite. |
|
Thread Tools | |
Display Modes | |
|
|