Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi ,
how can i create a folder in my computer, within the existed QVW file.
Thanks in advance for your replies.
Regards
Venkat
Hi,
Create a variable which will have qvpath stores.
For example Var = =QvWorkPath &'\ABC'&
Here ABC is a new directory name.
And then use below macro.
Sub abc
set Var = ActiveDocument.GetVariable("Path")
dim filesys, newfolder, newfolderpath
newfolderpath = Var.GetContent.String
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
msgbox("A new folder has been created at: " & newfolderpath)
End If
End sub
Regards,
Kaushik Solanki
Hi,
Here is the macro do create a folder.
Sub abc
dim filesys, newfolder, newfolderpath
newfolderpath = "D:\myfolder"
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
msgbox("A new folder has been created at: " & newfolderpath)
End If
End sub
Make sure that you have given a full right to run macro.i.e System Access in Macro.
Regards,
Kaushik Solanki
Hi Kaushik,
Thanks for Reply
Instead of providing the path of folder like this i.e; newfolderpath = "D:\myfolder"
Can we provide the path where the Current QVW exists i.e; where the current working QVW file exists there we need to provide the path.
Regards
Venkat
Hi Kaushik,
Thanks for reply
Instead of providing the path directly i.e; newfolderpath = "D:\myfolder"
Can we provide the path based on Current QVW file location i.e; it should create a folder where the current working QVW file is located.
Regards
Venkat
Hi,
Here is the macro for getting the applications path.
set temp = ActiveDocument.GetApplication.GetProperties
set path = temp.ApplicationPath
Hope it helps...
Hi,
Create a variable which will have qvpath stores.
For example Var = =QvWorkPath &'\ABC'&
Here ABC is a new directory name.
And then use below macro.
Sub abc
set Var = ActiveDocument.GetVariable("Path")
dim filesys, newfolder, newfolderpath
newfolderpath = Var.GetContent.String
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
msgbox("A new folder has been created at: " & newfolderpath)
End If
End sub
Regards,
Kaushik Solanki
Hi Kaushik,
Thanks, it is working in my QVW file.
Regards
Venkat
HI Kaushik,
I got an error when i am trying to create two folders at a time. I done below procedure, pls go through with this.
NOTE: If no folder of ABC then it is generating error message. Otherwise if it contains ABC folder then it is not showing error and creating the Username folder.
For example Var = =QvWorkPath &'\ABC'& QVUser() &'\'
Here ABC is a new directory name. In that i am trying to create another folder with Username.
Sub abc
set Var = ActiveDocument.GetVariable("Path")
dim filesys, newfolder, newfolderpath
newfolderpath = Var.GetContent.String
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
msgbox("A new folder has been created at: " & newfolderpath)
End If
End sub
Regards
Venkat
Hi,
As you said.
NOTE: If no folder of ABC then it is generating error message. Otherwise if it contains ABC folder then it is not showing error and creating the Username folder.
This is right.
If there is no Directory with name ABC then how can it create a new directory within it, and thus it is giving you an error.
So make sure that you have ABC directory created before you run the macro.
Regards,
Kaushik Solanki
Hi Kaushik,
Thanks for your suggestion
I tried what you said and its working. I given macro code like below
'*****Creating Group1 Folder***** //For Variable vGroup1Dir= =QvWorkPath &'\Group1'
dim filesys, newfolder, newfolderpath
newfolderpath = Var1.GetContent.String
Set filesys = CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
End If
End Sub
'*****Creating Group1\User Folder***** //For Variable vGroup1Users= =QvWorkPath&'\Group1\'&QVUser
()
Sub Group1Usersdim filesys, newfolder, newfolderpath
newfolderpath = Var3.GetContent.String
Set filesys = CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
msgbox("A New Folder is Created at : " &newfolderpath)
End If
End Sub
'*****Creating Group1\User\Text Folder*****
Sub TabDelimitedTextGroup1
set v1 = Activedocument.Variables("vGroup1Users")
set obj1 = ActiveDocument.GetSheetObject("CH46")
obj1.Export v1.GetContent.String &"\" &Date()&"_"&replace(Time(),":","")&".txt",","
MsgBox("Data Has Been Transfered")
End Sub
Regards
Venkat