I've been working on a printing macro with a quantity selection. Sometimes what I'm printing is very large and I convert it to bitmap so that the rip software processes it.I have a step in my code that if a checkbox is checked, convert to bitmap. But the issue I'm running into is that it drops my selection after that step. How do I keep my selection after it converts so I can continue with the printing code?
Sub B_PMWR() Dim groups As ShapeRange Dim group As Shape Dim groupname As String, path As String Set groups = ActiveSelectionRange Dim i As Long Dim pctdone As Single Dim doc As Document Set doc = ActiveDocument 'Optimize True ActiveDocument.BeginCommandGroup "Quantity" Quantity.Show ActiveDocument.EndCommandGroup 'Display Progress Bar ufProgress.LabelProgress.Width = 0 ufProgress.Show For i = 1 To groups.Count 'Update progress bar pctdone = i / groups.Count With ufProgress .LabelCaption.Caption = "Printing " & i & " of " & groups.Count .LabelProgress.Width = pctdone * (.FrameProgress.Width) End With DoEvents '-------the rest of your macro goes below here------- If Quantity.BitmapChk = True Then ' Set groups = ActiveSelectionRange.ConvertToBitmapEx(cdrCMYKColorImage, False, False, 300, cdrNormalAntiAliasing, False, False) ActiveSelectionRange.ConvertToBitmapEx cdrCMYKColorImage, False, False, 300, cdrNormalAntiAliasing, False, False groups.Selected = True 'ActivePage.Layers("1 (CMYK)").Activate 'Converting to Bitmap removes the active selection. Code stops. End If groupname = groups.Shapes(i).Name groups.Shapes(i).CreateSelection 'FIT TO PAGE: GMSManager.RunMacro "JQ_Fit_Page_To_Content", "JQ.Fit_Page_To_Content_No_Form" If ActivePage.SizeWidth > 129 Then If ActivePage.SizeHeight <= 36 Then With doc With .PrintSettings .SelectPrinter "B PMWR" .UsePPD = True .PPDFile = "C:\Program Files\Fiery\Fiery XF Universal Driver\Release\WinDll\i386x64\EFIUnidrv.PPD" .PageMatchingMode = prnPageMatchSizeAndOrientation .Copies = ActiveShape.Name End With .PrintOut End With End If Else If ActivePage.SizeHeight > 129 Then If ActivePage.SizeWidth <= 36 Then With doc With .PrintSettings .SelectPrinter "B PMWR" .UsePPD = True .PPDFile = "C:\Program Files\Fiery\Fiery XF Universal Driver\Release\WinDll\i386x64\EFIUnidrv.PPD" .PageMatchingMode = prnPageMatchSizeAndOrientation .Copies = ActiveShape.Name End With .PrintOut End With End If Else If ActivePage.SizeWidth <= 36 Or ActivePage.SizeHeight <= 36 Then With doc With .PrintSettings .PrintRange = prnSelection .SelectPrinter "B PMWR" 'enter printer name in between quotes to use that printer. .PageMatchingMode = prnPageMatchSizeAndOrientation .Copies = ActiveShape.Name End With .PrintOut End With End If End If End If 'For Prints on 60" Media If ActivePage.SizeWidth > 129 Then If ActivePage.SizeHeight > 36 Then With doc With .PrintSettings .SelectPrinter "C PMWR 60" .UsePPD = True .PPDFile = "C:\Program Files\Fiery\Fiery XF Universal Driver\Release\WinDll\i386x64\EFIUnidrv.PPD" .PageMatchingMode = prnPageMatchSizeAndOrientation .Copies = ActiveShape.Name End With .PrintOut End With End If Else If ActivePage.SizeWidth > 36 Then If ActivePage.SizeHeight > 36 Then With doc With .PrintSettings .PrintRange = prnSelection .SelectPrinter "C PMWR 60" 'enter printer name in between quotes to use that printer. .PageMatchingMode = prnPageMatchSizeAndOrientation .Copies = ActiveShape.Name End With .PrintOut End With End If End If End If '---------------------------------------------------- 'Close Progress Bar Next i Unload ufProgress 'Zoom Out To All Objects ActiveWindow.ActiveView.ToFitAllObjects 'Undo For Each group In groups ActiveDocument.Undo Next group ActiveDocument.Undo 'Optimize False End Sub
Jamie Chestnut said:I have a step in my code that if a checkbox is checked, convert to bitmap. But the issue I'm running into is that it drops my selection after that step. How do I keep my selection after it converts so I can continue with the printing code?
The ShapeRange.ConvertToBitmapEx method returns a Shape.
Use "Set" to get that Shape when you convert a ShapeRange to bitmap, and then use that later, if necessary, to create your selection.
So, something like:
Dim sCreatedBitmap as Shape
...
Set sCreatedBitmap = ActiveSelectionRange.ConvertToBitmapEx (cdrCMYKColorImage, False, False, 300, cdrNormalAntiAliasing, False, False)
s.CreatedBitmap.CreateSelection
Ok got past that section but it's getting stuck on the next one.Run-time error '-2147467259 (80004005)': The referenced object no longer existsgroupname = groups.Shapes(i).NameIn this situation where I'm bitmaping a large sign, I'm only going to be doing this one at a time. So maybe I could skip this line of code and just continue to the rest?
I had to set groups again. Working great now!sCreatedBitmap.CreateSelection Set groups = ActiveSelectionRange