Powershell: Error while calling the SaveAs Method of some Office Applications

Hi,

if you tried to save a word or excel document as another format you got an error. For example, if you want to convert a CSV File to a Excel workbook and save it in Excel 95/97/2003 format.

[reflection.assembly]::LoadWithPartialName("Microsoft.Office.InterOp.Excel")
$oExcel = New-Object -ComObject "Excel.Application"
$sCSVFile="D:\temp\ImportFile.csv"
$oExcel.Visible = $true
$oCSVWorkbook=$oExcel.Workbooks.Add()
$oExcel.Workbooks.OpenText($sCSVFile)
$oCSVWorkbook.SaveAs("D:\temp\test.xls",[Microsoft.Office.Interop.Excel.XlFileFormat]::xlExcel9795)
Exception calling "SaveAs" with "1" argument(s): "SaveAs method of Workbook class failed"
At D:\test\CSV2Excel.ps1:29 char:20
+ $xl_workbook.SaveAs <<<< ("D:\Temp\test.xls")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

Continue reading Powershell: Error while calling the SaveAs Method of some Office Applications

Advertisment to support michlstechblog.info

Windows: Hyper-V and Server Core start new cmd.exe

Hi,

you have closed the command shell window in your Session or you want to start an additional cmd shell or program?

At the console start the task Manager by pressing Alt-Ctrl-Del respectively if you are in a Remote Desktop Session Press Alt-Ctrl-End.

Start Task Manager
Start Task Manager

New Task
Continue reading Windows: Hyper-V and Server Core start new cmd.exe

Windows: Enable or disable Features from command line

Hi,

some usefull tools like telnet.exe are disabled by default in Windows Vista and later version. You can enable this and other features by command line using dism.
dism called with the get-features parameter lists all available features and its current state.
Note: Featurenames are case sensitive.
C:\>dism /online /Get-Features

.....
Feature Name : TelnetServer
State : Disabled

Feature Name : TelnetClient
State : Enabled
......

and the Enable-Feature option install them
Continue reading Windows: Enable or disable Features from command line

Virtualbox: Creating and controlling Virtual Maschines from command line

Hi,

VirtualBox offers a very powerful command inferface: vboxmanage. With vboxmanage you can create new virtual machine, add and modify harddisk and much more. All the things you could do in the GUI, and a lot more are also possible at command line. In this post I will create, modify, control and delete a complete virtual machine.

At the bottom of the post the whole script can be downloaded.
I used a debian linux system for my tests. To install the latest VirtualBox version use the following commands:

echo "deb http://download.virtualbox.org/virtualbox/debian wheezy contrib non-free" >> /etc/apt/sources.list
# Add Oracle Keyring
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
# Update repositories
apt-get update
# Install latest virtualbox version
apt-get -y install virtualbox-4.3
# Installing the Extentionpack for USB2 and RDP support
wget http://download.virtualbox.org/virtualbox/4.3.6/Oracle_VM_VirtualBox_Extension_Pack-4.3.6-91406.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.6-91406.vbox-extpack

Continue reading Virtualbox: Creating and controlling Virtual Maschines from command line

Subversion: Check out a project over http proxy server

Hi,

short post today. It is possible to anonymously checkout the latest version of a project over a http and a http proxy server. The only requierment is that the SVN respository must be available via http.

To define a proxy server open /etc/subversion/servers, locate the [global] section and add/edit the following properties:
Continue reading Subversion: Check out a project over http proxy server

My Knowledgebase for things about Linux, Windows, VMware, Electronic and so on…

Exit mobile version