Need help with macro to make selections and export it in txt format...??
Can any help me in writing the suitable macro with below requirements please.
select BM01 (Bookmark) and previous month ( to select prev month - use select in field option - field/column name is WellMonth and the exp Date(addmonths(Today()-1),'YYYY-MM')
Export the straight table (CH02) in txt format. ( file name should be YYYYMMDD_File1.txt ) then
clear all selections in the dashboard
select BM02 (Bookmark) and previous month ( to select prev month - use select in field option - field/column name is WellMonth and the exp Date(addmonths(Today()-1),'YYYY-MM') then
as we know the above macro will trigger a button. and above button contains 3 actions like - 1. clear all, 2. apply bookmark 3. run a macro.
3rd action run a macro should have to run the below macro which should make some selections in the dashboard and export the txt files with different names in the mentioned folder.
without adding the above small macro (trigger a button) below macro is working fine and generating the required files, but when we add both macros together we are not sure why but no files are generated. Please help us why this is happening....?
our expectation is - when we reload the app button should trigger and macro have to execute. tried post reload triggers as an alternate option but its not working either.
curMonth = Month( DateAdd("M",-1, Date))
if curMonth<10 then curMonthS="0" & CStr(curMonth) else curMonthS=CStr(curMonth)
IF curMonth=1 OR curMonth=3 OR curMonth=5 OR curMonth=7 OR curMonth=8 OR curMonth=10 OR curMonth=12 Then
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 0 to 1
strFile="F:\Test\Sch_section_" & wellNames(i) & "_UGS_01_" & curMonthS & "_" & noofdays & "_" & curMonthS & "_" & Year(Date) & ".txt"
Set MyFile = fso.CreateTextFile(strFile)
set table = ActiveDocument.GetSheetObject( "TB02" )
for RowIter = 0 to table.GetRowCount-1
set cell = table.GetCell(RowIter,0)
'set fso = CreateObject("Scripting.FileSystemObject")
Thanks Much in advance.
Export the straight table (CH04 )in txt format. ( file name should be YYYYMMDD_File2.txt )
I would discourage the use of macros, they should be a last resort when developing as the macro engine is a very old version, and it also forces a single-thread condition during calculations etc., which may have a significant performance impact upon the application too. I will let the others add their two cents, but that is about as much as I can offer on this one, I would find another means of doing what you are doing, we are not really an export tool, that is not the strength of the product, that analysis is the key focus of the product, so I am not sure why things are being exported out to be used in other tools...
To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question. I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
With the help of the APIGuide.qvw (within your QV install folder by automation) it should not be too difficult to develop such macro. There are various examples related to bookmarks (just search within the listboxes "Class" and "Member" for "*book*" and you will find many attributes and examples to them and also to other measures.
Of course you will need some trial & error to develop it step by step (some simplified dummy-app may be useful to learn how it worked instead of trying it within the final app) and by identifying the key-words for your tasks you could use them to search for them within the community (maybe someone else did something very similar and you could copy & paste from there some logic to speed up your task).