Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out-Word throws an Error "You cannot call a method on a null-valued expression": #6

Closed
samratashok opened this issue Dec 3, 2014 · 2 comments
Assignees
Labels

Comments

@samratashok
Copy link
Owner

Reported on my blog as comment:

http://www.labofapenetrationtester.com/2014/11/powershell-for-client-side-attacks.html?showComment=1417565010863#c4275766763153435120

I am currently looking in the issue, the solution proposed is:
http://www.labofapenetrationtester.com/2014/11/powershell-for-client-side-attacks.html?showComment=1417608458188#c7165076314488271651

Out-Word, namely "You cannot call a method on a null-valued expression":

Exception setting "DisplayAlerts": "Cannot convert value "False" to type "Micro
soft.Office.Interop.Word.WdAlertLevel". Error: "Invalid cast from 'System.Boole
an' to 'Microsoft.Office.Interop.Word.WdAlertLevel'.""
At C:\Users\test\Desktop\nishang\Client\Out-Word.ps1:127 char:11

  • $Word. <<<< DisplayAlerts = $False
  • CategoryInfo : InvalidOperation: (:) [], RuntimeException
  • FullyQualifiedErrorId : PropertyAssignmentException

You cannot call a method on a null-valued expression.
At C:\Users\test\Desktop\nishang\Client\Out-Word.ps1:202 char:54

  • $DocModule = $Doc.VBProject.VBComponents.Item <<<< (1)
  • CategoryInfo : InvalidOperation: (Item:String) [], RuntimeExcep
    tion
  • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Users\test\Desktop\nishang\Client\Out-Word.ps1:203 char:44

  • $DocModule.CodeModule.AddFromString <<<< ($code)
  • CategoryInfo : InvalidOperation: (AddFromString:String) [], Run
    timeException
  • FullyQualifiedErrorId : InvokeMethodOnNull

Argument: '1' should be a System.Management.Automation.PSReference. Use [ref].
At C:\Users\test\Desktop\nishang\Client\Out-Word.ps1:204 char:20

  • $Doc.Saveas <<<< ($OutputFile, 0)
  • CategoryInfo : NotSpecified: (:) [], MethodException
  • FullyQualifiedErrorId : NonRefArgumentToRefParameterMsg
@samratashok samratashok added the bug label Dec 3, 2014
@samratashok samratashok self-assigned this Dec 3, 2014
@samratashok
Copy link
Owner Author

I have been unable to reproduce this on Windows 7 and Office 2007. More feedback awaited from the original reporter.

@samratashok
Copy link
Owner Author

Fixed. Out-Word and Out-Excel now works with latest version of Ms Office (checked on trial Office 2013 professional)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant