#1
|
|||
|
|||
Need a macro that can shift an image and format it
Hi
I am new to VBA and macros, so any help would be greatly appreciated! I am using a premade word template that my database fills when I pull information. It is a label template. I am trying to make a macro to shift one element on this label because I am unable to reformat the template. When the database fills in the template it autogenerates a QR code (picture). I need to shift the QR code -6 increments to the left, and also format it so it sits behind the other text on the label. The behind function is important because the QR has a white background that overlaps with the text on the label. Alternatively I would consider cropping the QR code. I have tried writing my own macro and I was able to convert the image from inline to floating, have also been able to shift the image the -6 to the left. However when I change the wrap formatting to behind. things go awry. The first page of the document works well, but every page after that only 1 QR code is left visible on the page, and the rest have somehow disappeared. Any help would be great thank you! Here is my current VBA code Code:
Sub QR_Shift() ' ' QR_Shift Macro ' With ActiveDocument For i = .InlineShapes.Count To 1 Step -1 With .InlineShapes(i) If .Type = wdInlineShapePicture Then .ConvertToShape End If End With Next For i = 1 To .Shapes.Count With .Shapes(i) If .Type = msoPicture Then .WrapFormat.Type = wdWrapBehind End If End With Next For Each shap In ActiveDocument.Shapes shap.Select With .Shapes Selection.ShapeRange.IncrementLeft -6 End With Next End With End Sub Last edited by macropod; 01-06-2023 at 05:26 PM. Reason: Added code tags |
#2
|
||||
|
||||
The required approach depends on whether the QR code is inserted in-line or floating. In any event, the solution might require nothing more complicated than making the QR code image slightly smaller.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
I wish I could simply resize the QR code but it is already being generated at the smallest useable size.
Thank you though |
#4
|
||||
|
||||
I believe you'll find the white space around the QR code is part of the QR code specification. That may be a fixed amount of white space or a white space proportional to the size of the QR code itself. Its reduction or removal (including by repositioning within the label) is liable to compromise the integrity of any QR code scanning. Placing the code behind the text will cause the text to intrude on that white space and potentially to obscure parts of the QR code itself.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Thank you for the lesson on how QR codes work!
Thankfully the way the label template is set up there will always be room for the QR to have 'white space' around it (it gets printed on black metal so it's inverted), however the border is unnecessarily large. With the QR code being manually manipulated to be "behind text" (picture formatting not literally behind text) and shifted to the left, it still functions. I just need a macro to repeat this process. Best. |
#6
|
||||
|
||||
In that case, simply changing the table cell border size may be all you need. That should be done once - in the mailmerge main document - before the merge is executed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
image, macro, picutre |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I create a macro to shift the content of all subsequent footnotes up one position? | Atfon | Word VBA | 4 | 03-29-2016 05:51 AM |
Shift Excel Cell after executing a macro for second time | LearningMacro | Excel Programming | 2 | 01-08-2015 03:05 PM |
1.image in a table 2.right click 3.menu click format 4.a format column appears | OldFatDog | Drawing and Graphics | 1 | 06-13-2014 11:19 PM |
Noob here - I need a shift calendar by days with count of shift. | freeman | Excel | 8 | 09-12-2012 08:45 AM |
Vector image format | jespestana | Drawing and Graphics | 4 | 11-26-2010 03:51 AM |