win32ole

How to save Excel file in working directory in Win32::OLE

点点圈 提交于 2019-12-12 01:42:18
问题 I am trying to parse an Excel file in perl. After I extract the required info from it, I close the Excel file. At the end I am trying to save a new Excel file with a different name in the same directory. But this Excel is getting stored in 'My Documents' folder. use Storable ; use Cwd; use Win32::OLE ; use Win32::OLE qw(in with) ; use Win32::OLE in ; use Win32::OLE::Const 'Microsoft Excel'; use Excel::Writer::XLSX; my $Excel = Win32::OLE->new("Excel.Application"); my $excel = $Excel-

How do I query a MS Access database table, and export the information to Excel using Ruby and win32ole?

假如想象 提交于 2019-12-11 06:04:05
问题 I'm new to Ruby, and I'm trying to query an existing MS Access database for information for a report. I want this information stored in an Excel file. How would I do this? 回答1: Try one of these: OLE: require 'win32ole' class AccessDbExample @ado_db = nil # Setup the DB connections def initialize filename @ado_db = WIN32OLE.new('ADODB.Connection') @ado_db['Provider'] = "Microsoft.Jet.OLEDB.4.0" @ado_db.Open(filename) rescue Exception => e puts "ADO failed to connect" puts e end def table_to

Read MS Word .doc file with ruby and win32ole

风流意气都作罢 提交于 2019-12-11 05:27:21
问题 I'm trying to read .doc file with ruby, I use win32ole library. IT my code: require 'win32ole' class DocParser def initialize @content = '' end def read_file file_path begin word = WIN32OLE.connect( 'Word.Application' ) doc = word.activedocument rescue word = WIN32OLE.new( 'Word.Application' ) doc = word.documents.open( file_path ) end word.visible = false doc.sentences.each{ |x| @content = @content + x.text } word.quit @content end end I kick off doc reading with DocParser.new.read_file(

How do I apply formatting to a particular word in a docx file using Win32::Ole in Perl?

心不动则不痛 提交于 2019-12-09 22:59:30
问题 For example, my docx file contains the following sentences: This is a Perl example This is a Python example This is another Perl example I want to apply bold style to all the occurrences of the word "Perl" like so: This is a Perl example This is a Python example This is another Perl example I've so far come up with the following script: use strict; use warnings; use Win32::OLE::Const 'Microsoft Word'; my $file = 'E:\test.docx'; my $Word = Win32::OLE->new('Word.Application', 'Quit'); $Word->{

Ruby program with win32ole does not work any more under Windows7 64bit

試著忘記壹切 提交于 2019-12-09 19:39:49
问题 I have an old ruby program that extracts values from an excel file and stores the summary in another excel file. For that purpose, the program uses the library win32ole from Ruby. After switching to a new computer with Windows 7 64bit (instead of Windows XP 32bit), Office 2007 instead of Office 2003, the program now throws an error when storing the resulting excel file: ana.rb:120:in `method_missing': SaveAs (WIN32OLERuntimeError) OLE error code:800A03EC in Microsoft Office Excel 'c:/my/dir'

what's gem can operate Excel on linux?

◇◆丶佛笑我妖孽 提交于 2019-12-07 16:19:12
问题 My users will update their Excel to my system and I will get some information from it, I know the gem that named "win32OLE" on windows is run well, but my system is ubuntu, so how can I operate it? 回答1: The Ruby Spreadsheet gem will work for you https://rubygems.org/gems/spreadsheet 回答2: You can have a look at roo and parseescelas well. 来源: https://stackoverflow.com/questions/7428997/whats-gem-can-operate-excel-on-linux

Read MS Word table data row wise using win32:ole perl

最后都变了- 提交于 2019-12-07 04:26:43
问题 I am new to win32:ole module in perl. I am trying to print MS word table data row wise on command prompt. But I am able to print only last row of the table. Can you please help me to solve this problem? Thanks in advance. Below is my code: #!/usr/bin/perl use strict; use warnings; use File::Spec::Functions qw( catfile ); use Win32::OLE qw(in); use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; my $word = get_word(); $word->{DisplayAlerts} = wdAlertsNone; $word->{Visible} = 1; my

sending ctrl+c using sendkeys in ruby

送分小仙女□ 提交于 2019-12-06 14:13:43
I need to close the command prompt window using sendkeys function, but when I used the below code it did not work as running of some betch file is in progress so its not taking these below options. require 'win32ole' system("start cmd.exe") sleep(5) # Create an instance of the Wscript Shell: wsh = WIN32OLE.new('Wscript.Shell') # Try to activate the command window: if wsh.AppActivate('cmd.exe') sleep(1) wsh.SendKeys('cd \\') wsh.SendKeys('{ENTER}') # change the directory path where mtn folder is residing wsh.SendKeys('cd ') wsh.SendKeys "C://mtn-3//mtn-2.2//" wsh.SendKeys('{ENTER}') wsh

Register a proxy/stub in HKEY_CURRENT_USER

瘦欲@ 提交于 2019-12-06 04:28:42
The MIDL compiler generates code for a proxy/stub with registration routines that write to HKEY_LOCAL_MACHINE. Is there any way (preferably without hacking the MIDL-generated code and without bypassing all that generated code in favor of custom code) to register a MIDL-generated p/s in HKEY_CURRENT_USER? Also: Will this work if both the p/s and the COM server are registered per-user like this? I just found (after a very frustrating 48 hours) that a p/s registered machine-wide will not work correctly if the COM server is registered per-user. Specifically, the asynchronous call logic

what's gem can operate Excel on linux?

纵然是瞬间 提交于 2019-12-05 23:11:56
My users will update their Excel to my system and I will get some information from it, I know the gem that named "win32OLE" on windows is run well, but my system is ubuntu, so how can I operate it? The Ruby Spreadsheet gem will work for you https://rubygems.org/gems/spreadsheet You can have a look at roo and parseescel as well. 来源: https://stackoverflow.com/questions/7428997/whats-gem-can-operate-excel-on-linux