Automatic Numbering

Started by jamuka, November 11, 2015, 12:46:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamuka

Hello all,

first I want to apoligize my question, I'm sure it has an easy solution but visio is totally out of my knowledge. I ended up with responsibility to print a workflow created on visio.

It has an unique ID (i.e (62/001, 62/002 etc.) and it has an macro, where you can enter "from" "to" numbers so you can print without changing number for each time. But I couldn't figure out how to use macro.

I can't attach visio file due to size of it, but I attached the VBA code. Visio file has two sheet called "sc cover sheet" and "sc cover sheet p2".

I hope this information will be enough and once again sorry for my ignorance about visio.


Update: I'll follow the Yacine's advice and adding the code here and deleting the doc file.

Dim UniqueID As Integer
Private Const CSetID As String = "60/"
Private Const CNumPages As Integer = 2
Private Const CPrinter As String = "\\10.2.1.20\TRT100-Common"

Sub printingWF()
    Dim i As Integer
    UniqueID = 0
    For i = 1 To CNumPages
        Call SetWFID
        Call print1wfs
    Next i
End Sub

Sub printingLF()
    Dim i As Integer
    UniqueID = 0
    For i = 1 To CNumPages
        Call SetLFID
        Call print1lfs
    Next i
End Sub


' ### WorkFlowSheets
Private Sub SetWFID()
    UniqueID = UniqueID + 1

    Application.ActiveDocument.Pages.ItemU("sc cover sheet").Shapes.ItemFromID(20).Characters.Text = Format(UniqueID, "000")
    Application.ActiveDocument.Pages.ItemU("sc cover sheet").Shapes.ItemFromID(23).Characters.Text = CSetID

    Application.ActiveDocument.Pages.ItemU("sc cover sheet p2").Shapes.ItemFromID(6).Characters.Text = Format(UniqueID, "000")
    Application.ActiveDocument.Pages.ItemU("sc cover sheet p2").Shapes.ItemFromID(25).Characters.Text = CSetID
End Sub

Private Sub print1wfs()
    Application.ActiveDocument.PrintOut PrintRange:=visPrintFromTo, FromPage:=1, _
         ToPage:=2, PrinterName:=CPrinter
End Sub


' ### Listing Forms
Private Sub SetLFID()
    UniqueID = UniqueID + 1
   
    Dim vsoCharacters1 As Visio.Characters
    Dim vsoCharacters2 As Visio.Characters
   
    Set vsoCharacters1 = Application.ActiveDocument.Pages.ItemU("SC listing form").Shapes.ItemFromID(61).Characters
    vsoCharacters1.Text = Format(UniqueID, "000")
End Sub

Private Sub print1lfs()
    Application.ActiveDocument.PrintOut PrintRange:=visPrintFromTo, FromPage:=3, _
         ToPage:=3, PrinterName:=CPrinter
End Sub





Yacine

#1
Hi Jumaka,
The doc file is corrupt - needed notepad++ to open it.
The forum offers a nice feature to post code. Insert the code, select it and press the "hash" button on top of the editing box.
Your code:

Dim UniqueID As Integer
Private Const CSetID As String = "60/"
Private Const CNumPages As Integer = 2
Private Const CPrinter As String = "\\10.2.1.20\TRT100-Common"


Sub printingWF()
    Dim i As Integer
    UniqueID = 0
    For i = 1 To CNumPages
        Call SetWFID
        Call print1wfs
    Next i
End Sub


Sub printingLF()
    Dim i As Integer
    UniqueID = 0
    For i = 1 To CNumPages
        Call SetLFID
        Call print1lfs
    Next i
End Sub


' ########################################################################################
' ### WorkFlowSheets
Private Sub SetWFID()
    UniqueID = UniqueID + 1

    Application.ActiveDocument.Pages.ItemU("sc cover sheet").Shapes.ItemFromID(20).Characters.Text = Format(UniqueID, "000")
    Application.ActiveDocument.Pages.ItemU("sc cover sheet").Shapes.ItemFromID(23).Characters.Text = CSetID


    Application.ActiveDocument.Pages.ItemU("sc cover sheet p2").Shapes.ItemFromID(6).Characters.Text = Format(UniqueID, "000")
    Application.ActiveDocument.Pages.ItemU("sc cover sheet p2").Shapes.ItemFromID(25).Characters.Text = CSetID
End Sub


Private Sub print1wfs()
    Application.ActiveDocument.PrintOut PrintRange:=visPrintFromTo, FromPage:=1, _
         ToPage:=2, PrinterName:=CPrinter
End Sub


' ########################################################################################
' ### Listing Forms
Private Sub SetLFID()
    UniqueID = UniqueID + 1
   
    Dim vsoCharacters1 As Visio.Characters
    Dim vsoCharacters2 As Visio.Characters
   
    Set vsoCharacters1 = Application.ActiveDocument.Pages.ItemU("SC listing form").Shapes.ItemFromID(61).Characters
    vsoCharacters1.Text = Format(UniqueID, "000")
End Sub


Private Sub print1lfs()
    Application.ActiveDocument.PrintOut PrintRange:=visPrintFromTo, FromPage:=3, _
         ToPage:=3, PrinterName:=CPrinter
End Sub
Yacine

Yacine

From what I read, you need to run the macro "printingWF".
To run a macro, you need to enable macros, then press ALT+F8, chose the right one and click run.
Yacine

jamuka

Hello Yacine,


thank you for your answer. The problem is there's no "run" button in macro window,I searched the net yet couldn't find a solution for it.  I attached the screenshot of visio file and macro window.
Also sorry for the doc file.

regards




Yacine

Yacine

jamuka

well, I don't know what to say :-[.

I'm used to see it above the "step into" but I shouldn't make assumptions where my knowledge is zero. lesson learnt.

again, thank you very much for your help Yacine.

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 213 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1104KB.
Tokens: post-login.
Cache hits: 14: 0.00213s for 26,583 bytes (show)
Cache misses: 3: (show)
Queries used: 15.

[Show Queries]