- Registriert
- 03.01.08
- Beiträge
- 3.831
Hallo.
Ich arbeite mich gerade frisch in Applescript ein, anhand eines echten Problems:
Wir fügen in Worddokumente oft Grafiken ein. Diese als "Inhalt einfügen" -> "Bild". (Da sie oft aus Quellen kommen wie z.B. PowerPoint oder irgendein verquertes DrawingObject sind/waren.)
Nun funktioniert aber die Einstellung "in line with text" im Word nur für CMD-V (also nicht "Inhalt einfügen" sondern nur "einfügen", was es nicht immer als Bild macht. Daher war die Idee ein Applescript zu schreiben, das das kann, nämlich ein selektiertes Bild in ein "in line with text" shape zu wandeln.
Was geht ist das:
tell application "Microsoft Word"
activate active document
repeat with s in (get shapes in active document)
if shape type of s is shape type picture then
convert to inline shape s
end if
end repeat
if shape type of s is shape type picture then
convert to inline shape s
end if
end tell
Das aber wandelt ALLE Bilder im Dokument so um.
Die Idee war nun, dass NUR DAS SELEKTIERTE Bild umzuwandeln ist aber das geht nicht.
Folgendes Testprogramm wirf immer aus "Was sonst?" obwohl ein Bild aktiviert ist.
tell application "Microsoft Word"
activate active document
set s to selection
if shape type of s is shape type picture then
display dialog "BILD!"
else
display dialog "Was sonst?"
end if
end tell
Wie spricht man selektierte Bilder an? Ich finde nichts. Geht das nicht?
Danke!
Ich arbeite mich gerade frisch in Applescript ein, anhand eines echten Problems:
Wir fügen in Worddokumente oft Grafiken ein. Diese als "Inhalt einfügen" -> "Bild". (Da sie oft aus Quellen kommen wie z.B. PowerPoint oder irgendein verquertes DrawingObject sind/waren.)
Nun funktioniert aber die Einstellung "in line with text" im Word nur für CMD-V (also nicht "Inhalt einfügen" sondern nur "einfügen", was es nicht immer als Bild macht. Daher war die Idee ein Applescript zu schreiben, das das kann, nämlich ein selektiertes Bild in ein "in line with text" shape zu wandeln.
Was geht ist das:
tell application "Microsoft Word"
activate active document
repeat with s in (get shapes in active document)
if shape type of s is shape type picture then
convert to inline shape s
end if
end repeat
if shape type of s is shape type picture then
convert to inline shape s
end if
end tell
Das aber wandelt ALLE Bilder im Dokument so um.
Die Idee war nun, dass NUR DAS SELEKTIERTE Bild umzuwandeln ist aber das geht nicht.
Folgendes Testprogramm wirf immer aus "Was sonst?" obwohl ein Bild aktiviert ist.
tell application "Microsoft Word"
activate active document
set s to selection
if shape type of s is shape type picture then
display dialog "BILD!"
else
display dialog "Was sonst?"
end if
end tell
Wie spricht man selektierte Bilder an? Ich finde nichts. Geht das nicht?
Danke!