#1
|
|||
|
|||
Good tutorials for ListBox /CombiBox (tweaking MsgBox)?
I've Got a simple VBA code from here, to rotate inlineshapes, either selected, or all in Word document. Looking for an easy to follow tutorial to select the rotation value of either -90°, 90° or 180°. (you can only apply rotation once via macro).I will want to add the variable of selected or all with Combibox, but struggling to get ListBox to work first. I have just found this link to tweak MsgBox:
https://wellsr.com/vba/2019/excel/create-advanced-vba-msgbox-custom-buttons/ so will try it, but may not be able to have 5 buttons, and I can't use unecessary code when rolling out to colleagues. Does anyone else have a simpler tweak of MsgBox? Need to understand ListBox and CombiBox. All the online searches are for Embedded within Excel which I don't want to do. |
#2
|
||||
|
||||
The best choice would be to create a userform where you can design an interface to give the users the best experience.
The simplest coding choice is to use an InputBox and tell them what to enter via a key Code:
Sub PickOne() Dim iResp As Integer, sMsg As String sMsg = "Selected Pictures:" & vbCr & " Type 1 for 90 degrees" & vbCr & _ " Type 2 for 180 degrees" & vbCr & " Type 3 for -90 degrees" & vbCr & vbCr & _ "All Pictures:" & vbCr & " Type 4 for 90 degrees" & vbCr & _ " Type 5 for 180 degrees" & vbCr & " Type 6 for -90 degrees" iResp = InputBox(sMsg, "Make a Selection", "1") Debug.Print iResp End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thanks, will set up in next few days and check I get it to work, and remember to put this web page as a note in the macro for credit and reference.
For Context I have created a Macro t to save customer Outlook Item as text, and Macro A to save all attachments ready for upload - this saves to a folder up a level from Macro t, and kills /deletes the previous running of Macro A. I have created a Macro T to save a customer Outlook item as docx, the advantage being that embedded photos of docs from customer mobiles are captured and these are not attachments. Still trying to resolve the paste K as images are oversized and my macro just imputs all objects/items. I will post all these macros when done. Once this Macro R for rotate is resolved, I will be able to do macro C to compress images in docx Macro T further beyond natural good compression, to 150ppi or 95ppi, as we have a 4MB upload limit to a customer system. I intend to do a Macro I to paste all image attachments at the end of Macro T active document. And similarly Macro W for doc, docx or rtf attachments, but some thought is needed if practical as need to code page break, and break the Header and Footer links - might be better to copy opened doc/rtf and copy and paste, as increasingly editors lock editable settings, or have password and won't work. Should be able to combine Macros T, I, W and c(150ppi as 95ppi can make text unreadable). We use CutePdf Writer which is a bit fiddly, but there is some code on their website so a Cute macro may be possible for maximum file compression via print in Adobe Reader, colleagues don't know how to reverse the page running order or rotate pages before printing to correct.Very large pdfs are a pain to split into smaller sections under 4MB, maybe a CuteS macro can be created. Our IT Dept might be able to use RPA to OCR pdfs and correct orientation of pdfs and other images in Macro T - we don't have Adobe Professional to manually do compression,split or general formatting. I am manually print screening landscape full screen from Adobe and pasting into my docx manually created from forwarding the email and selecting the body to paste which wraps/justifies all embedded images but does not include the attachment list. We have a real problem with so many unspecified files being uploaded and there are massive delays in processing and rereading the data, so I instinctively put everything I can in one docx manually, with a good file description. For macro t, T and A, I have used this site which is very helpful://www.slipstick.com/outlook-developers/developer-index/ |
#4
|
|||
|
|||
Hi Guessed,I tried the InputBox, it works as a standalone sub. Just not sure how to link to my rotation macros, do I need to assign the value for rotation seperately for the InputBox selections? I tried deleting out degrees after the rotation value, and making it a private sub, each time replacing the rotation value with "PickOne". I guess I am going to have to combine Macro r and Macro R into one, with the permutations executing after the InputBox in an or scenario? Thanks James Martin
Code:
Sub MacrorSelectedImage() Application.ScreenUpdating = False Dim iShp As InlineShape, Shp As Shape For Each iShp In Selection.Inlineshapes 'For Sub MacroRSelectAllImages() insert this line: 'For Each iShp In ActiveDocument.InlineShapes With iShp If .Type = wdInlineShapePicture Then Set Shp = .ConvertToShape With Shp .Rotation = 90 .ConvertToInlineShape End With End If End With Next Application.ScreenUpdating = True End Sub Quote:
|
#5
|
||||
|
||||
I would do it with a sub and a function. This is a bit fuller featured in that you can type in things more things than the basic 1, 2, 3, or 4. For instance, try 0.5 or -0.5. Note that if you run this code on pictures more than once it reveals that each rotation is always relative to the ORIGINAL graphic orientation so you could put 0 into the dialog to set the graphic(s) back to the original orientation.
Code:
Sub RotateOnIt() Dim inShp As InlineShape, aRng As Range, iResp As Double, iResp2 As Double, sMsg As String, sMsg2 As String sMsg = "Selected Picture(s):" & vbCr & " Type 1 for 90 degrees" & vbCr & " Type 2 for 180 degrees" & vbCr & " Type 3 for -90 degrees" sMsg2 = sMsg & vbCr & vbCr & "Ask me each time:" & vbCr & " Type 4" Set aRng = Selection.Range If aRng.InlineShapes.Count = 1 Then iResp = InputBox(sMsg, "Make a Selection", "1") ElseIf aRng.InlineShapes.Count > 1 Then iResp = InputBox(sMsg2, "Make a Selection", "1") Else MsgBox "You must select inline shapes first.", vbExclamation + vbOKOnly, "Almost..." Exit Sub End If For Each inShp In aRng.InlineShapes If inShp.Type = wdInlineShapePicture Then Select Case iResp Case Is < 4 PicRotate inShp, iResp Case 4 inShp.Range.Select iResp2 = InputBox(sMsg, "Make a Selection", "1") PicRotate inShp, iResp2 End Select End If Next End Sub Function PicRotate(inShp As InlineShape, iRot As Double) Dim Shp As Shape Set Shp = inShp.ConvertToShape Shp.Rotation = iRot * 90 Shp.ConvertToInlineShape End Function
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Could somebody help me with the code of my VBA userforms(Combibox - saving - editing of data) | 19339 | Excel Programming | 2 | 09-14-2018 12:06 AM |
anyone knows any good tutorials on recording macros in Word? | thanh | Word | 1 | 08-16-2017 06:16 AM |
Good tutorials on recording macros in Microsoft Word | nathan123 | Word VBA | 2 | 05-22-2015 10:54 AM |
Good tutorials on macros | karen.drummond2 | Word VBA | 2 | 04-04-2013 07:33 AM |
Good Tutorials for Reccording Macro's | Rohan | Word | 1 | 01-09-2010 11:08 AM |