This code requires a sheet with cells named "FilePath" (which must end in a "\"), "StartExt" (original file extension), and "EndExt" (desired file extension). Thanks for the ideas! I used the above ideas to make a macro to do a bulk file conversion-convert every file of one format in a folder to another format. Export Filename:=str, Filtername:="jpeg"Īpplication.Calculation = xlCalculationAutomatic PageSetup.RightMargin = IIf(h > dh, dw - dh * w / h, dw - w) + 36 PageSetup.TopMargin = IIf(w > dw, dh - dw * h / w, dh - h) + 28 Str = "C:\Users\YOURUSERNAMEHERE\Desktop\Screenshot.jpeg" Keybd_event vbKeyMenu, 0, 2, 0 'sendkeys alt+printscreen doesn't work Keybd_event vbKeyMenu, 0, 0, 0 'these do just active window If Application.StatusBar = False Then Application.StatusBar = "EVENTS DISABLED" Private Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)ĭim tmp As Variant, str As String, h As Double, w As DoubleĪpplication.Calculation = xlCalculationManual Takes about 1 second to print the screenshot to target path. Note that I've named one of my worksheets wsTMP, you can replace it with Sheet1 or the like. Note that the maximum image size is limited and the aspect ratio is ever so slightly off, as I was not able to perfectly optimize the reshaping math. It took a long time to make this, but it does a pretty good job. New versions of excel have made old answers obsolete. Export ("H:\Webshop_Zpider\Strukturbildene\" & strImageName & ".jpg") Set oDia = (0, 0, oShape.Width, oShape.Height) = 0.5: = 0.5: = msoPictureAutomatic: = msoFalse: = msoFalse: = msoFalse: = 0#: = 0#: = 0#: = 0#: = 0#: 1#, msoTrue, msoScaleFromTopLeft: 1#, msoTrue, msoScaleFromTopLeft StrImageName = ActiveSheet.Cells(, 1).Value I don't remember the specifics about all those ChartObjects and whatnot, but here it is: For Each oShape In ActiveSheet.Shapes Here's a piece of code i used a while ago, roughly adapted to your needs. If i remember correctly, you need to use the "Shapes" property of your sheet.Įach Shape object has a TopLeftCell and BottomRightCell attributes that tell you the position of the image.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |