1 Reply Latest reply: Nov 18, 2011 11:11 AM by Fernando Suzuki RSS

Copy Variable value to Excel sheet via Macro

Debbie Pyykkonen

I created a macro to write copy objects and write values to Excel.  I have a variable called vMaxOrderTimeStamp and I can see the variable has an actual value but the following code in my macro will not copy the value to the Excel spreadsheet.  What am I missing?   Doesn't work: objExcelDoc.Sheets("About").Range("C8") = vMaxOrderTimeStamp  All of the code below works perfectly except this one line:  '// Finally select the About sheet objExcelDoc.Sheets("About").Select objExcelDoc.Sheets("About").Range("B2") = chartCaption objExcelDoc.Sheets("About").Range("C4") = "Qlikview Capacity Dashboard Export via AccessPoint" objExcelDoc.Sheets("About").Range("C6") = "Review and Forecast head count "  objExcelDoc.Sheets("About").Range("C9") = " SAP (Orders), SFDC (Case History - Phone for Premier), and Avaya (Phone for BC & FD)"   I then need to figure out how to get the current User Name and export that value as well as the current date Today():  objExcelDoc.Sheets("About").Range("C5") = "Get User Name of person exporting" 'Need to figure out how to get the user name to populate objExcelDoc.Sheets("About").Range("C7") = " Get Current Date" 'Need to figure out how to get current date

  • Re: Copy Variable value to Excel sheet via Macro
    Fernando Suzuki

    Hi,

     

    to get a variable's value, use the code:

    set v = ActiveDocument.Variables("Variable1")

    msgbox(v.GetContent.String)

     

    to get the user name, you can create a variable in your QVW and use this expression:

    OSUser()

     

     

    and then in the macro you can get the variable's value as described above.

     

    To get the current date, you can use a variable, or you can use the VBScript funcion "now()".

     

     

    Hope this helps you

    Regards,

    Fernando