Please explain how to make applescript understand I want to select all images on the active page (which in my case are going to be one), to resize the image and fit frame to content.
tell application "Adobe InDesign CS6"
set myPagecount to count pages of active document
repeat with i from 1 to myPagecount
set thisImage to select every graphic frame of page i
tell content of thisImage
set height to "11in"
set width to "8.5in"
fit given frame to content
end tell
end repeat
end tell
This obviously doesn't work...
Thanks!
Just to give you some ideas:
tell application "Adobe InDesign CS5.5"
activate
set myPagecount to count pages of active document
tell active document
set myPage to page 1
tell page myPage
tell item 1 of all graphics of myPage
set geometric bounds of it to {10, 10, 0, 0}
end tell
end tell
end tell
end tell
Just reference your page and loop through the collection of all graphics. You will need to change values for geometric bounds, use quotation marks for inches ("8.5in").
=================================
Edited:
The code above actually resizes graphics/pdf inside the frame. I added 2 versions - one for the pdf and one for the frame. You need to set your values in geometric bounds
tell application "Adobe InDesign CS6"
activate
set myPagecount to count pages of active document
tell active document
set myPage to page 1
tell page myPage
tell item 1 of all graphics of myPage
set geometric bounds of it to {100, 100, 0, 0}
end tell
tell text frame 1 of myPage
set geometric bounds of it to {100, 100, 0, 0}
end tell
end tell
end tell
end tell
This is the final answer - thanks to nicolai.kant!
tell application "Adobe InDesign CS6"
set myPagecount to count pages of active document
tell active document
repeat with i from 1 to myPagecount
set myPage to page i
tell page myPage
tell item 1 of all graphics of myPage
set geometric bounds of it to {"8.5in", "11in", 0, 0}
fit given frame to content
end tell
end tell
end repeat
end tell
end tell
Related
I have small problem, does anyone know how to change position of existing dimensions and Notes in Part/Product using short macro.
I will shortly describe what I want to do and what kind of problem I have.
I have simple model (let say rectangle)
Inside this model I have dimensions and annotations created in FTA.
Next step is to drastically change position of this model (base model in point 0,0,0 and I want tochange it position to 150,10000,80 + rotation)
during this change some dimensions and annotations (Theirs position in 3D) are not fully following after geometry.
Because of that I would like to have simple macro to create new position of my dimensions and annotations after part update.
I have performed some simple tests code bellow
What I have noticed, when I set new position of the text:
Theoretically text change position but in 3D it stays in old position.
When edit my text by double click on it and then click OK my text translates to new position which was set in macro earlier. The same situation is when I would like to change frame of the text or content (I had AAA and I would like to have BBB), it's changes only when I open Text editor.
Set part1 = CATIA.ActiveDocument
Set Selection = part1.Selection
Set VisPropertySet = Selection.VisProperties
Selection.Search ("name='Text.1',all")
' get selected annotation here
Dim anAnnotation As Annotation
Set anAnnotation = CATIA.ActiveDocument.Selection.Item(1).Value
' get annotation on the DrawingText interface
Dim txtAnnotation As DrawingText
Set txtAnnotation = anAnnotation.Text.Get2dAnnot()
' get TPS view that contains annotation on the DrawingView interface
Dim vwTPSView As DrawingView
Set vwTPSView = txtAnnotation.Parent.Parent
' get coordinates on a view
Dim dX ' as Double
txtAnnotation.X = 0
txtAnnotation.Y = 30
txtAnnotation.FrameType = catEllipse
part1.Update
End Sub
Generally using Part.Update refreshes the annotation's position and text but you can also use:
Dim anAnnotation As Annotation
'Code here
anAnnotation.ModifyVisu 'This should work for both Texts and Dimensions
But if the above method does not work, you can try reseting the text on the annotation (It will work only for texts, and not for dimensions)
Dim vwTPSView As DrawingView
'Code here
vwTPSView.Text = vwTPSView.Text
Be carefull with this last methos though. If your text has any parameters or variables inside it, replacing the text will clear it.
How can I adjust Microsoft Word's footer height using VBA in Word 2010?
I have tried recording a macro but the height information doesn't get recorded.
It's the FooterDistance property of the PageSetup object. The example below sets it to 1":
With ActiveDocument.PageSetup
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(1)
End With
The property, that can be read or set is
activedocument.PageSetup.FooterDistance
Unit is in dots based on a 72 DPI, meaning fhat if you set the value to 72, that will give you a 2.54 cm or 1 inch footer
Hope that helps
Daniel
I didn't see an answer for this, so here is mine:
The height of an empty footer is the BottomMargin minus the FooterDistance.
The margin size determines the maximum size for the whole footer (including the FooterDistance (white space)).
The FooterDistance will determine how close to the edge of the page the text will get rendered. (be aware that your actual printer margins will chop off stuff that is too close to the edge)
Note: If you already have stuff in your footer and if the text and/or images in the footer has a larger total height - Word will make the footer taller to hold it all.
The sample code below will resize your footer.
Dim sHght As Single
With ActiveDocument.PageSetup
sHght = .BottomMargin ' get existing margin in points
.BottomMargin = sHght + 10 ' increase margin (size of space for footer)
.FooterDistance = CentimetersToPoints(1) ' set to suit your printer
End With
I am creating an add-in using VB.NET VSTO for MS-Word. In this program I need to retrieve the details such as Location (Left, Top) and Size (Height, Weight) of all the images on the document. I also want to retrieve the page number where the image is located. I use the following code,
Dim i As Integer
For i = 1 To Globals.ThisAddIn.Application.ActiveDocument.InlineShapes.Count
If Globals.ThisAddIn.Application.ActiveDocument.InlineShapes(i).Type = Word.WdInlineShapeType.wdInlineShapePicture Then
strHeight = Globals.ThisAddIn.Application.ActiveDocument.InlineShapes(i).ScaleHeight()
strWidth = Globals.ThisAddIn.Application.ActiveDocument.InlineShapes(i).ScaleWidth()
End If
Next i
However, this can only retrieve the Size (Height, Weight). How to get the Location (Left, Top) and page number of the image?
By its very nature, an InlineShape doesn't have a positionable top and left. It's, well, inline, which means it exists in the text layer of the document and the location floats depending on the text and/or other content before it. If the item is on page 2, and you insert 25 lines of text or another picture before InlineShape(i), said shape will float down to page 3 (or 4 or whatever.)
The height and width ARE accessible, simply by using .Height and .Width. ScaleHeight and ScaleWidth are properties that reflect the size of the object in the document relative to the original size of the object. You probably want to store the height and width as strings, though, since the property returns a single (numeric) value. For height and width:
Dim i As Integer
Dim shp as InlineShape
For i = 1 To Globals.ThisAddIn.Application.ActiveDocument.InlineShapes.Count
shp = Globals.ThisAddIn.Application.ActiveDocument.InlineShapes(i)
If shp.Type = Word.WdInlineShapeType.wdInlineShapePicture Then
strHeight = shp.Height.ToString()
strWidth = shp.Width.ToString()
End If
Next i
To get the page number, you have to reference the range of the InlineShape.
shp.Range.get_Information(Word.WdInformation.wdActiveEndPageNumber)
You can also get the top and left position of the image (although it might not do you any good, depending on why you want it). The get_Information method also has wdHorizontalPositionRelativeToPage and wdVerticalPositionRelativeToPage
I'm fairly new to VBA coding. I am trying to capture a photo from a slide. The photo is outlined by a rectangle. There are text boxes and arrows inside the rectangle that I am trying to capture. I know I can group the object and export the shape as the group. It would be better for my situation if it was not necessary to group the objects. The current code does save a photo of the rectangle, but not the other shapes on top of it.
Dim photoA As Variant
Set photoA = Application.ActiveWindow.View.Slide.Shapes("Rectangle 2")
With photoA
.Export "A.jpg", ppShapeFormatJPG
End With
I'm writing a simple app that's going to have a tiny form sitting in one corner of the screen, updating itself.
I'd really love for that form to be transparent and to have the transparency be user-configurable.
Is there any easy way to achieve this?
You could try using the Opacity property of the Form. Here's the relevant snippet from the MSDN page:
private Sub CreateMyOpaqueForm()
' Create a new form.
Dim form2 As New Form()
' Set the text displayed in the caption.
form2.Text = "My Form"
' Set the opacity to 75%.
form2.Opacity = 0.75
' Size the form to be 300 pixels in height and width.
form2.Size = New Size(300, 300)
' Display the form in the center of the screen.
form2.StartPosition = FormStartPosition.CenterScreen
' Display the form as a modal dialog box.
form2.ShowDialog()
End Sub
Set Form.Opacity = 0.0 on page load
I set something like what your talking about on an app about a year ago. Using a While loop with a small Sleep you can setup a nice fading effect.
I don't know exactly what you mean by transparent, but if you use WPF you can set AllowTransparency = True on your form and then remove the form's style/border and then set the background to a color that has a zero alpha channel. Then, you can draw on the form all you want and the background will be see-through and the other stuff will be fully visible. Additionally, you could set the background to a low-opacity layer so you can half see through the form.
You can set the Form.Opacity property. It should do what you want.