The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fill in Word Document form fields - VBA in QM
#1
Hi All,
I came across some sample VBA code for updating a Word form field:
http://www.devhut.net/2010/09/17/vba-wor...rm-fields/

I was trying to do it in QM but unsuccessfully:

Code:
Copy      Help
VARIANT* filepath  =  "C:\SampleDoc.docx"
typelib Word {00020905-0000-0000-C000-000000000046} 8.5
;_s.expandpath(filepath)
Word.Application oApp._create
Word.Document oDoc = oApp.documents.open(filepath)
oApp.Visible = "true"
oDoc.FormFields("PtNameField").Result = "John Doe"
oDoc.Close
;



I had first defined filepath as a string str but I received this error from QM

Quote:Error in Macro: expected VARIANT*
tip: maybe you can use operator & (address) or + (type cast) or @ (string to UTF-16).

So I changed str to VARIANT* which threw an exception but seemed to work when I changed it to just VARIANT without the asterisk.

It then tried to open the document successfully but the next line didn't seem to be the right syntax

Code:
Copy      Help
oDoc.FormFields("PtNameField").Result = "John Doe"

FormFields seems to be a read only property and doesn't take the .Result member.

Any thoughts on how to proceed further with setting the text of that field?

Thanks!!!!,
S


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)