This question already has answers here:
Print certain pages only
(2 answers)
Closed 2 years ago.
I can't seem to get Words PrintOut to accept/honor the parameter for PAGES when run in VBScript. Weirdly, it honors COPIES just fine. Any ideas?
Code:
Dim ObjWord
Set ObjWord = CreateObject("Word.Application")
ObjWord.Visible = True
'Open Document
Dim ObjDoc
'https://learn.microsoft.com/en-us/office/vba/api/word.documents.open
'.Open (FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible, OpenConflictDocument, OpenAndRepair, DocumentDirection, NoEncodingDialog)
Set ObjDoc = ObjWord.Documents.Open("C:\tmp\test.docx", ,TRUE, , , , , , , , ,TRUE)
'PageRange
'https://learn.microsoft.com/en-us/office/vba/api/word.application.printout
'.PrintOut (Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight)
Dim ObjPrint
ObjPrint = ObjDoc.PrintOut(FALSE, , , , , , , ,"1", , ,TRUE) ' No Error, but Pages not honored
'ObjPrint = ObjDoc.PrintOut(FALSE, , , , , , ,"2", , , ,TRUE) ' Corretly Printes Two Copies
objDoc.Saved = TRUE
objWord.Quit
Set ObjDoc = Nothing
Set objWord = Nothing
So I had to pass an additional param for it to honour the Pages value which was Range.
https://learn.microsoft.com/en-us/office/vba/api/word.document.printout
https://documentation.help/MS-Office-Word-VB/womthPrintOut1.htm
It required a CONSTANT declaration. Eg:
https://learn.microsoft.com/en-us/office/vba/api/word.wdprintoutrange
Specifies a range to print.
WDPRINTOUTRANGE ENUMERATION (WORD)
Name Value Description
wdPrintAllDocument 0 The entire document.
wdPrintCurrentPage 2 The current page.
wdPrintFromTo 3 A specified range.
wdPrintRangeOfPages 4 A specified range of pages.
wdPrintSelection 1 The current selection.
In my case, I believe it will always be 4.
Therefore this worked as expected. (Print Only Page 2)
ObjPrint = ObjDoc.PrintOut(FALSE, ,"4", , , , , ,"2", , ,TRUE)
Further Reading on Printing Word via VBScript. Disclaimer: This is my personal blog --> https://www.freesoftwareservers.com/display/FREES/Print+Microsoft+Word+via+Batch+-+WINWORD.EXE+Switches+-+VBScript+Print+Specific+Pages
In my Grails 2.4.4 app I am using messages.properties for internationalization, with the following value:
my.app.thing.allowance(s)={0} Allowance(s)
and it is being using in a gsp like so:
<g:message code="my.app.thing.allowance(s)" args="${item.allowances.size()}"/>
the message is correctly displayed for any values greater than 0, for example if item.allowances.size() == 4 then the message displayed is 4 Allowances(s)
the issue is that if item.allowances.size() == 0 then the message displayed is {0} Allowance(s)
I have tried to write the args in several different ways, for example:
<g:message code="my.app.thing.allowance(s)" args="${item.allowances.isEmpty() ? 0.intValue() : item.allowances.size()}"/>
I have debugged things and I am sure that item.allowances.size() == 0 but for some reason it can not handle a value of 0 properly. What is the correct way to pass an argument with an int value of 0 to messages.properties?
In g.message arguments are always passed as an List.
From: http://docs.grails.org/3.0.17/ref/Tags/message.html
args (optional) - A list of argument values to apply to the message when code is used.
Try this code instead:
<g:message code="my.app.thing.allowance(s)" args="[item.allowances.size()]"/>
The Bharat's answer is correct, but I want to add why it happened so:
You have passed args=0
And here it is code from message tag lib:
List args = []
if (attrs.args) {
args = attrs.encodeAs ? attrs.args as List : encodeArgsIfRequired(attrs.args)
}
In groovy 0 is false, that's why you didn't have filled in message in case of ZERO
Hi I'm trying to use morphline inteceptor and convert my syslog to JSON
for start i tried to use split command for splitting my string ,but im getting error as below:
"" Source r1 has been removed due to an error during configuration
com.typesafe.config.ConfigException$WrongType: /root/flume.17/conf/morph.conf: 21: Cannot concatenate object or list with a non-object-or-list, ConfigString("split") and SimpleConfigObject({"outputFields":"substrings","inputField":"message","addEmptyStrings":false,"isRegex":false,"trim":true,"separator":" "}) are not compatible""
my morphline configuration file:
morphlines : [
{
# Name used to identify a morphline. E.g. used if there are multiple
# morphlines in a morphline config file
id : morphline1
# Import all morphline commands in these java packages and their
# subpackages. Other commands that may be present on the classpath are
# not visible to this morphline.
importCommands : ["org.kitesdk.**"]
commands : [
{
# Parse input attachment and emit a record for each input line
readLine {
charset : UTF-8
}
}
,split {
inputField : message
outputFields : "substrings"
separator : " "
isRegex : false
addEmptyStrings : false
trim : true }
}
}
]
}
]
what do i have to do?I'm new to this
From morhpline documentation
outputField - The name of the field to add output values to, i.e. a single string. Example: tokens. One of outputField or outputFields must be present, but not both.
outputFields - The names of the fields to add output values to, i.e. a list of strings. Example: [firstName, lastName, "", age]. An empty string in a list indicates omit this column in the output. One of outputField or outputFields must be present, but not both.
So you should just specify
outputField : substrings
instead of
outputFields : "substrings"
http://kitesdk.org/docs/1.1.0/morphlines/morphlines-reference-guide.html#split
I am trying to import a ms-excel 2007 sheet using excel-import plugin. It was simple to integrate with my project and I found it working as expected until I noticed that the number values in the cells are populated as real numbers with exponent.
For example if the cell contains value 9062831150099 -(populated as)->9.062831150099E12 i.e.
A |
_____________________
Registration Number |
____________________
9062831150099
Is populated as: [RegNum:9.062831150099E12]
Anyone could suggest me how I can change this representation back to its original format keeping its type as number?
Missed it at the first attempt but I figured out how to to achieve it:
When invoking the key methods (the ones that process cellMap and columnMaps) for example List bookParamsList = excelImportService.columns(workbook, CONFIG_BOOK_COLUMN_MAP) or Map bookParams = excelImportService.cells(workbook, CONFIG_BOOK_CELL_MAP )
There is also ability to pass in configuration information, i.e. to specify what to do if a cell is empty (i.e. to provide a default value), to make sure a cell is of expected type, etc.
So in my case I created a configuration parameter Map of properties of the object and passed it to the above methods. i.e.
Class UploadExcelDataController {
def excelImportService
static Map CONFIG_BOOK_COLUMN_MAP = [
sheet:'Sheet1',
startRow: 2,
columnMap: [
'A':'registrationNumber',
'B':'title',
'C':'author',
'D':'numSold',
]
]
static Map configBookPropertyMap = [
registrationNumber: ([expectedType: ExpectedPropertyType.IntType, defaultValue:0])
]
def uploadFile(){
...
List bookParamsList = excelImportService.columns(workbook, CONFIG_BOOK_COLUMN_MAP,configBookPropertyMap )
...
}
}
I was getting lately an error in Lua saying cannot assign arithmetic value of '?'. then I realized that I need to define how many storage are in my array and assigning them to a value,
this gave me Error : locator = {}
this Worked fine : locator = {0,0,0,0,0,0,0,0,0,0}
So now I have another array that I need a loop to store 200 values in it, so how to define the storage and values within it without something like this : a = {0,0,0,0,0,...... etc}
Any Ideas ?
this is what worked for me :
locator = {}
for i = 1, 200 do
locator[i] = 0
end
just assigning all to 0 inside a loop Before using them
Credits : Egor Skriptunoff