Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace the VBA code with the Qm code error
#1
I want to convert VBA code into Qm code, but there is a mistake, because I programming level is not good, plagued me for many days, I hope someone can help me, thank you very much :oops:

VBA code:
Sub SetNewRange()
Dim ran As Range
Set ran = ActiveDocument.Range(Start:=0, End:=10)
End Sub

QM code:
Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 1
out

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive ;;connect to Word. Note: need the /exe 1.
Word.Document doc=app.ActiveDocument
Word.Range ran=doc.Range(Start=0 End=10)

out ran

;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {EB126AB4-AFF9-4818-9E31-A62869FFF810}
;END PROJECT


Attached Files Image(s)
   
#2
The following code can not succeed too :oops:

Sub SetBoldRange()
ActiveDocument.ActiveWindow.Panes(1).Selection.Cut
End Sub

Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 1
out

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive ;;connect to Word. Note: need the /exe 1.
Word.Document doc=app.ActiveDocument
doc.ActiveWindow.Panes(1).Selection.Cut


;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {EB126AB4-AFF9-4818-9E31-A62869FFF810}
;END PROJECT


Attached Files Image(s)
   
#3
doc.ActiveWindow.Panes.Item(1).Selection.Cut
#4
Thank you very much, Successful! Big Grin but I do not understand why the VBA code do not have (Item), but it can be successful :?:

Where is the error in the following code? Can you remind me about it? thank you very much
Word.Range ran=doc.Range(Start=0 End=10)
#5
The following VBA code can run successfully, but the QM code is still error

Sub FormatFirstParagraph()
Dim aRange As Range
Set aRange = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(2).Range.Start, End:=ActiveDocument.Paragraphs(4).Range.End)
With aRange
.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphCenter
With .Font
.Name = "Stencil"
.Size = 15
End With
End With
End Sub


Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 1
out

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive ;;connect to Word. Note: need the /exe 1.
Word.Document doc=app.ActiveDocument
;doc.ActiveWindow.Panes(1).Selection.Cut
Word.Range ran=doc.Range(Start=doc.Paragraphs(2).Item.Range.Start, End:=doc.Paragraphs.Item(4).Range.End)
ran.Bold="True"
ran.Font.Size=15
ran.Font.Name="Stencil"


;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {EB126AB4-AFF9-4818-9E31-A62869FFF810}
;END PROJECT


Attached Files Image(s)
   
#6
Can not use the (end) keyword? How to solve this problem? Confusedhock:
#7
I used the QM code to delete the form and an error occurred :oops:

VBA:
Sub deletetable()
For Each v In ActiveDocument.Tables
v.Delete
Next
MsgBox "ok"
End Sub

QM:
Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 1

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive
Word.Document doc=app.ActiveDocument
VARIANT v
foreach v doc.Tables
,v.Delete

;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {3DA97B40-4C34-45B9-B34D-CAC175C705BC}
;END PROJECT


Attached Files Image(s)
   
#8
Use the following code to succeed :wink:

Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 1

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive
Word.Document doc=app.ActiveDocument
Word.Table v
foreach v doc.Tables
,v.Delete

;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {3DA97B40-4C34-45B9-B34D-CAC175C705BC}
;END PROJECT
#9
Tongue

Macro Macro1
Trigger SF9     Help - how to add the trigger to the macro
Code:
Copy      Help
;/exe 1

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive
Word.Document doc=app.ActiveDocument
Word.Tables ts=doc.Tables
Word.Table t
foreach t ts
,t.Delete

;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {3DA97B40-4C34-45B9-B34D-CAC175C705BC}
;END PROJECT
#10
Gintaras Wrote:doc.ActiveWindow.Panes.Item(1).Selection.Cut

Hello, can i use the "pointer" to solve the following constituency question? can you give me an example? This question bothers me for many days, thank you very much Tongue
#11
The following code, the operation failed :oops:

Macro Macro2
Code:
Copy      Help
;/exe 1
out

typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive ;;connect to Word. Note: need the /exe 1.
Word.Document doc=app.ActiveDocument
Word.Range ran=doc.Range(Start=doc.Paragraphs.Item(2).Range.Start End=doc.Paragraphs.Item(4).Range.End)
ran.Bold="True"
ran.Font.Size=15
ran.Font.Name="Stencil"


;BEGIN PROJECT
;main_function  Macro1
;exe_file  $my qm$\Macro1.qmm
;flags  6
;guid  {EB126AB4-AFF9-4818-9E31-A62869FFF810}
;END PROJECT
#12
Try this:
Macro Macro5
Code:
Copy      Help
;/exe 1
out
typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive ;;connect to Word. Note: need the /exe 1.
Word.Document doc=app.ActiveDocument
VARIANT StartRange=doc.Paragraphs.Item(2).Range.Start
VARIANT EndRange=doc.Paragraphs.Item(4).Range.End
Word.Range ran=doc.Range(StartRange EndRange)
ran.Bold=1
ran.Font.Size=15
ran.Font.Name="Stencil"
#13
Thank you very much for your help, running successfully, your thinking is awesome Big Grin
#14
Start_Learning Wrote:Try this:
Macro Macro5
Code:
Copy      Help
;/exe 1
out
typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._getactive ;;connect to Word. Note: need the /exe 1.
Word.Document doc=app.ActiveDocument
VARIANT StartRange=doc.Paragraphs.Item(2).Range.Start
VARIANT EndRange=doc.Paragraphs.Item(4).Range.End
Word.Range ran=doc.Range(StartRange EndRange)
ran.Bold=1
ran.Font.Size=15
ran.Font.Name="Stencil"

Do You know the following VBA code, how to modify the QM code? thanks in advance Smile

Word.Range ran=doc.Range(Start=0 End=10)
#15
QM in the following code can be streamlined? For example, VBA will use the(with) statement

Ran.Bold = 1
Ran.Font.Size = 15
Ran.Font.Name = "Stencil"

VBA(use with):

With aRange
.Bold = True
With .Font
.Name = "Stencil"
.Size = 15
End With
End With
#16
kyjdp Wrote:Do You know the following VBA code, how to modify the QM code? thanks in advance Smile
Word.Range ran=doc.Range(Start=0 End=10)
Same concept:
Code:
Copy      Help
VARIANT StartRange=0
VARIANT EndRange=10
Word.Range wRange=doc.Range(StartRange EndRange)
#17
Thank you very much, my brains are too stupid, but also need to continue to study hard :lol:


Forum Jump:


Users browsing this thread: 1 Guest(s)